﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using MSWord = Microsoft.Office.Interop.Word;
//using Excel = Microsoft.Office.Interop.Excel;
using Microsoft.Office.Interop.Word;
using System.Windows.Forms;
using Microsoft.Office.Core;
//using PWMS.DataClass;
using System.Data.SqlClient;
using System.Data;
using DBUtility;

namespace 一键生成
{
    class CreateWord2
    {
        object path;//文件路径
        string strContent;//文件内容
        MSWord.Application wordApp;//Word应用程序变量
        MSWord.Document wordDoc;//Word文档变量
        //string str = "Data Source=PC-20170315GPTA;Initial Catalog=HSXH;Integrated Security=True";
        string str = @"Data Source=192.168.1.214;Initial Catalog=HSXH;User ID=sa;Password=Ningtu2015";
        //创建资料汇编
        public void CreatWorkExplain(string Str, string timer1)
        {
            string str;
            object path;//文件路径
            string strContent;//文件内容
            MSWord.Application wordApp;//Word应用程序变量
            MSWord.Document wordDoc;//Word文档变量
            path = "d:\\垂直位移观测表.doc";//保存为Word2003文档
            // path = "d:\\myWord.doc";//保存为Word2007文档
            wordApp = new MSWord.ApplicationClass();//初始化
            object unite = Microsoft.Office.Interop.Word.WdUnits.wdStory;
            if (File.Exists((string)path))
            {
                File.Delete((string)path);
            }
            Object Nothing = Missing.Value;
            wordDoc = wordApp.Documents.Add(ref Nothing, ref Nothing, ref Nothing, ref Nothing);
            //页面设置
            wordDoc.PageSetup.PaperSize = Microsoft.Office.Interop.Word.WdPaperSize.wdPaperA4;//设置纸张样式
            wordDoc.PageSetup.Orientation = Microsoft.Office.Interop.Word.WdOrientation.wdOrientPortrait;//排列方式为垂直方向
            wordDoc.PageSetup.TopMargin = 57.0f;
            wordDoc.PageSetup.BottomMargin = 57.0f;
            wordDoc.PageSetup.LeftMargin = 57.0f;
            wordDoc.PageSetup.RightMargin = 57.0f;
            wordDoc.PageSetup.HeaderDistance = 30.0f;//页眉位置
            //设置页眉
            wordApp.ActiveWindow.View.Type = Microsoft.Office.Interop.Word.WdViewType.wdOutlineView;//视图样式
            wordApp.ActiveWindow.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekPrimaryHeader;//进入页眉设置，其中页眉边距在页面设置中已完成
            wordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
            //插入页眉图片(测试结果图片未插入成功)(Paragraph段落格式Format格式Alignment对齐)
            //wordApp.Selection.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;
            //string headerfile = "d:\\1.jpg";
            //Microsoft.Office.Interop.Word.InlineShape shape1 = wordApp.ActiveWindow.ActivePane.Selection.InlineShapes.AddPicture(headerfile, ref Nothing, ref Nothing, ref Nothing);
            //shape1.Height = 20;
            //shape1.Width = 80;
            wordApp.ActiveWindow.ActivePane.Selection.InsertAfter("2015年观测资料汇编                                                                           滨海抽水站");
            wordApp.ActiveWindow.ActivePane.Selection.Font.Bold = 0;
            wordApp.ActiveWindow.ActivePane.Selection.Font.Name = "宋体";//页眉的字体
            //去掉页眉的横线
            wordApp.ActiveWindow.ActivePane.Selection.ParagraphFormat.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].LineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleSingle;
            wordApp.ActiveWindow.ActivePane.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].Visible = false;
            wordApp.ActiveWindow.ActivePane.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekMainDocument;//退出页眉设置
            //为当前页添加页码
            Microsoft.Office.Interop.Word.PageNumbers pns = wordApp.Selection.Sections[1].Headers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterEvenPages].PageNumbers;//获取当前页的号码
            pns.NumberStyle = Microsoft.Office.Interop.Word.WdPageNumberStyle.wdPageNumberStyleNumberInDash;
            pns.HeadingLevelForChapter = 0;
            pns.IncludeChapterNumber = false;
            pns.RestartNumberingAtSection = false;
            pns.StartingNumber = 0;
            object pagenmbetal = Microsoft.Office.Interop.Word.WdPageNumberAlignment.wdAlignPageNumberCenter;//将号码设置在中间
            object first = true;
            wordApp.Selection.Sections[1].Footers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterEvenPages].PageNumbers.Add(ref pagenmbetal, ref first);



            CZWYGCB_old(unite, Nothing, wordApp, wordDoc, Str, timer1);

            //关闭保存word
            object format = MSWord.WdSaveFormat.wdFormatDocument;
            wordDoc.SaveAs(ref path, ref format, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);
            wordDoc.Close(ref Nothing, ref Nothing, ref Nothing);
            wordApp.Quit(ref Nothing, ref Nothing, ref Nothing); //关闭wordApp组件对象
            //Response.Write("<script>alert('" + path + ": Word文档格式设置完毕!');</script>");
            MessageBox.Show("操作完成");
        }
        public void CreatWorkExplain2(string timer1, string timer2, string timer3)
        {
            string str;
            object path;//文件路径
            string strContent;//文件内容
            MSWord.Application wordApp;//Word应用程序变量
            MSWord.Document wordDoc;//Word文档变量
            path = "d:\\基点高程考证表.doc";//保存为Word2003文档
            // path = "d:\\myWord.doc";//保存为Word2007文档
            wordApp = new MSWord.ApplicationClass();//初始化
            object unite = Microsoft.Office.Interop.Word.WdUnits.wdStory;
            if (File.Exists((string)path))
            {
                File.Delete((string)path);
            }
            Object Nothing = Missing.Value;
            wordDoc = wordApp.Documents.Add(ref Nothing, ref Nothing, ref Nothing, ref Nothing);
            //页面设置
            wordDoc.PageSetup.PaperSize = Microsoft.Office.Interop.Word.WdPaperSize.wdPaperA4;//设置纸张样式
            wordDoc.PageSetup.Orientation = Microsoft.Office.Interop.Word.WdOrientation.wdOrientPortrait;//排列方式为垂直方向
            wordDoc.PageSetup.TopMargin = 57.0f;
            wordDoc.PageSetup.BottomMargin = 57.0f;
            wordDoc.PageSetup.LeftMargin = 57.0f;
            wordDoc.PageSetup.RightMargin = 57.0f;
            wordDoc.PageSetup.HeaderDistance = 30.0f;//页眉位置
            //设置页眉
            wordApp.ActiveWindow.View.Type = Microsoft.Office.Interop.Word.WdViewType.wdOutlineView;//视图样式
            wordApp.ActiveWindow.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekPrimaryHeader;//进入页眉设置，其中页眉边距在页面设置中已完成
            wordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
            //插入页眉图片(测试结果图片未插入成功)(Paragraph段落格式Format格式Alignment对齐)
            //wordApp.Selection.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;
            //string headerfile = "d:\\1.jpg";
            //Microsoft.Office.Interop.Word.InlineShape shape1 = wordApp.ActiveWindow.ActivePane.Selection.InlineShapes.AddPicture(headerfile, ref Nothing, ref Nothing, ref Nothing);
            //shape1.Height = 20;
            //shape1.Width = 80;
            wordApp.ActiveWindow.ActivePane.Selection.InsertAfter("2015年观测资料汇编                                                                           滨海抽水站");
            wordApp.ActiveWindow.ActivePane.Selection.Font.Bold = 0;
            wordApp.ActiveWindow.ActivePane.Selection.Font.Name = "宋体";//页眉的字体
            //去掉页眉的横线
            wordApp.ActiveWindow.ActivePane.Selection.ParagraphFormat.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].LineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleSingle;
            wordApp.ActiveWindow.ActivePane.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].Visible = false;
            wordApp.ActiveWindow.ActivePane.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekMainDocument;//退出页眉设置
            //为当前页添加页码
            Microsoft.Office.Interop.Word.PageNumbers pns = wordApp.Selection.Sections[1].Headers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterEvenPages].PageNumbers;//获取当前页的号码
            pns.NumberStyle = Microsoft.Office.Interop.Word.WdPageNumberStyle.wdPageNumberStyleNumberInDash;
            pns.HeadingLevelForChapter = 0;
            pns.IncludeChapterNumber = false;
            pns.RestartNumberingAtSection = false;
            pns.StartingNumber = 0;
            object pagenmbetal = Microsoft.Office.Interop.Word.WdPageNumberAlignment.wdAlignPageNumberCenter;//将号码设置在中间
            object first = true;
            wordApp.Selection.Sections[1].Footers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterEvenPages].PageNumbers.Add(ref pagenmbetal, ref first);



            JDGCKZB(unite, Nothing, wordApp, wordDoc, timer1, timer2, timer3);

            //关闭保存word
            object format = MSWord.WdSaveFormat.wdFormatDocument;
            wordDoc.SaveAs(ref path, ref format, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);
            wordDoc.Close(ref Nothing, ref Nothing, ref Nothing);
            wordApp.Quit(ref Nothing, ref Nothing, ref Nothing); //关闭wordApp组件对象
            //Response.Write("<script>alert('" + path + ": Word文档格式设置完毕!');</script>");
            MessageBox.Show("操作完成");
        }
        public void CreatWorkExplain3(string Str1, string Str2)
        {
            string str;
            object path;//文件路径
            string strContent;//文件内容
            MSWord.Application wordApp;//Word应用程序变量
            MSWord.Document wordDoc;//Word文档变量
            path = "d:\\垂直位移工作基点考证表.doc";//保存为Word2003文档
            // path = "d:\\myWord.doc";//保存为Word2007文档
            wordApp = new MSWord.ApplicationClass();//初始化
            object unite = Microsoft.Office.Interop.Word.WdUnits.wdStory;
            if (File.Exists((string)path))
            {
                File.Delete((string)path);
            }
            Object Nothing = Missing.Value;
            wordDoc = wordApp.Documents.Add(ref Nothing, ref Nothing, ref Nothing, ref Nothing);
            //页面设置
            wordDoc.PageSetup.PaperSize = Microsoft.Office.Interop.Word.WdPaperSize.wdPaperA4;//设置纸张样式
            wordDoc.PageSetup.Orientation = Microsoft.Office.Interop.Word.WdOrientation.wdOrientPortrait;//排列方式为垂直方向
            wordDoc.PageSetup.TopMargin = 57.0f;
            wordDoc.PageSetup.BottomMargin = 57.0f;
            wordDoc.PageSetup.LeftMargin = 57.0f;
            wordDoc.PageSetup.RightMargin = 57.0f;
            wordDoc.PageSetup.HeaderDistance = 30.0f;//页眉位置
            //设置页眉
            wordApp.ActiveWindow.View.Type = Microsoft.Office.Interop.Word.WdViewType.wdOutlineView;//视图样式
            wordApp.ActiveWindow.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekPrimaryHeader;//进入页眉设置，其中页眉边距在页面设置中已完成
            wordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
            //插入页眉图片(测试结果图片未插入成功)(Paragraph段落格式Format格式Alignment对齐)
            //wordApp.Selection.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;
            //string headerfile = "d:\\1.jpg";
            //Microsoft.Office.Interop.Word.InlineShape shape1 = wordApp.ActiveWindow.ActivePane.Selection.InlineShapes.AddPicture(headerfile, ref Nothing, ref Nothing, ref Nothing);
            //shape1.Height = 20;
            //shape1.Width = 80;
            wordApp.ActiveWindow.ActivePane.Selection.InsertAfter("2015年观测资料汇编                                                                           滨海抽水站");
            wordApp.ActiveWindow.ActivePane.Selection.Font.Bold = 0;
            wordApp.ActiveWindow.ActivePane.Selection.Font.Name = "宋体";//页眉的字体
            //去掉页眉的横线
            wordApp.ActiveWindow.ActivePane.Selection.ParagraphFormat.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].LineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleSingle;
            wordApp.ActiveWindow.ActivePane.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].Visible = false;
            wordApp.ActiveWindow.ActivePane.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekMainDocument;//退出页眉设置
            //为当前页添加页码
            Microsoft.Office.Interop.Word.PageNumbers pns = wordApp.Selection.Sections[1].Headers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterEvenPages].PageNumbers;//获取当前页的号码
            pns.NumberStyle = Microsoft.Office.Interop.Word.WdPageNumberStyle.wdPageNumberStyleNumberInDash;
            pns.HeadingLevelForChapter = 0;
            pns.IncludeChapterNumber = false;
            pns.RestartNumberingAtSection = false;
            pns.StartingNumber = 0;
            object pagenmbetal = Microsoft.Office.Interop.Word.WdPageNumberAlignment.wdAlignPageNumberCenter;//将号码设置在中间
            object first = true;
            wordApp.Selection.Sections[1].Footers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterEvenPages].PageNumbers.Add(ref pagenmbetal, ref first);



            CZWYGZJDKZB(unite, Nothing, wordApp, wordDoc, Str1, Str2);
            // CZWYLBHTJB(unite, Nothing, wordApp, wordDoc, Str);
            //关闭保存word
            object format = MSWord.WdSaveFormat.wdFormatDocument;
            wordDoc.SaveAs(ref path, ref format, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);
            wordDoc.Close(ref Nothing, ref Nothing, ref Nothing);
            wordApp.Quit(ref Nothing, ref Nothing, ref Nothing); //关闭wordApp组件对象
            //Response.Write("<script>alert('" + path + ": Word文档格式设置完毕!');</script>");
            MessageBox.Show("操作完成");
        }
        public void CreatWorkExplain5(string Str)
        {
            string str;
            object path;//文件路径
            string strContent;//文件内容
            MSWord.Application wordApp;//Word应用程序变量
            MSWord.Document wordDoc;//Word文档变量
            path = "d:\\垂直位移量变化统计表.doc";//保存为Word2003文档
            // path = "d:\\myWord.doc";//保存为Word2007文档
            wordApp = new MSWord.ApplicationClass();//初始化
            object unite = Microsoft.Office.Interop.Word.WdUnits.wdStory;
            if (File.Exists((string)path))
            {
                File.Delete((string)path);
            }
            Object Nothing = Missing.Value;
            wordDoc = wordApp.Documents.Add(ref Nothing, ref Nothing, ref Nothing, ref Nothing);
            //页面设置
            wordDoc.PageSetup.PaperSize = Microsoft.Office.Interop.Word.WdPaperSize.wdPaperA4;//设置纸张样式
            wordDoc.PageSetup.Orientation = Microsoft.Office.Interop.Word.WdOrientation.wdOrientPortrait;//排列方式为垂直方向
            wordDoc.PageSetup.TopMargin = 57.0f;
            wordDoc.PageSetup.BottomMargin = 57.0f;
            wordDoc.PageSetup.LeftMargin = 57.0f;
            wordDoc.PageSetup.RightMargin = 57.0f;
            wordDoc.PageSetup.HeaderDistance = 30.0f;//页眉位置
            //设置页眉
            wordApp.ActiveWindow.View.Type = Microsoft.Office.Interop.Word.WdViewType.wdOutlineView;//视图样式
            wordApp.ActiveWindow.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekPrimaryHeader;//进入页眉设置，其中页眉边距在页面设置中已完成
            wordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
            //插入页眉图片(测试结果图片未插入成功)(Paragraph段落格式Format格式Alignment对齐)
            //wordApp.Selection.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;
            //string headerfile = "d:\\1.jpg";
            //Microsoft.Office.Interop.Word.InlineShape shape1 = wordApp.ActiveWindow.ActivePane.Selection.InlineShapes.AddPicture(headerfile, ref Nothing, ref Nothing, ref Nothing);
            //shape1.Height = 20;
            //shape1.Width = 80;
            wordApp.ActiveWindow.ActivePane.Selection.InsertAfter("2015年观测资料汇编                                                                           滨海抽水站");
            wordApp.ActiveWindow.ActivePane.Selection.Font.Bold = 0;
            wordApp.ActiveWindow.ActivePane.Selection.Font.Name = "宋体";//页眉的字体
            //去掉页眉的横线
            wordApp.ActiveWindow.ActivePane.Selection.ParagraphFormat.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].LineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleSingle;
            wordApp.ActiveWindow.ActivePane.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].Visible = false;
            wordApp.ActiveWindow.ActivePane.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekMainDocument;//退出页眉设置
            //为当前页添加页码
            Microsoft.Office.Interop.Word.PageNumbers pns = wordApp.Selection.Sections[1].Headers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterEvenPages].PageNumbers;//获取当前页的号码
            pns.NumberStyle = Microsoft.Office.Interop.Word.WdPageNumberStyle.wdPageNumberStyleNumberInDash;
            pns.HeadingLevelForChapter = 0;
            pns.IncludeChapterNumber = false;
            pns.RestartNumberingAtSection = false;
            pns.StartingNumber = 0;
            object pagenmbetal = Microsoft.Office.Interop.Word.WdPageNumberAlignment.wdAlignPageNumberCenter;//将号码设置在中间
            object first = true;
            wordApp.Selection.Sections[1].Footers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterEvenPages].PageNumbers.Add(ref pagenmbetal, ref first);


            CZWYLBHTJB(unite, Nothing, wordApp, wordDoc, Str);
            //关闭保存word
            object format = MSWord.WdSaveFormat.wdFormatDocument;
            wordDoc.SaveAs(ref path, ref format, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);
            wordDoc.Close(ref Nothing, ref Nothing, ref Nothing);
            wordApp.Quit(ref Nothing, ref Nothing, ref Nothing); //关闭wordApp组件对象
            //Response.Write("<script>alert('" + path + ": Word文档格式设置完毕!');</script>");
            MessageBox.Show("操作完成");
        }
        public void CreatWorkExplain4()
        {
            string str;
            object path;//文件路径
            string strContent;//文件内容
            MSWord.Application wordApp;//Word应用程序变量
            MSWord.Document wordDoc;//Word文档变量
            path = "d:\\myWord.doc";//保存为Word2003文档
            // path = "d:\\myWord.doc";//保存为Word2007文档
            wordApp = new MSWord.ApplicationClass();//初始化
            object unite = Microsoft.Office.Interop.Word.WdUnits.wdStory;
            if (File.Exists((string)path))
            {
                File.Delete((string)path);
            }
            Object Nothing = Missing.Value;
            wordDoc = wordApp.Documents.Add(ref Nothing, ref Nothing, ref Nothing, ref Nothing);
            //页面设置
            wordDoc.PageSetup.PaperSize = Microsoft.Office.Interop.Word.WdPaperSize.wdPaperA4;//设置纸张样式
            wordDoc.PageSetup.Orientation = Microsoft.Office.Interop.Word.WdOrientation.wdOrientPortrait;//排列方式为垂直方向
            wordDoc.PageSetup.TopMargin = 57.0f;
            wordDoc.PageSetup.BottomMargin = 57.0f;
            wordDoc.PageSetup.LeftMargin = 57.0f;
            wordDoc.PageSetup.RightMargin = 57.0f;
            wordDoc.PageSetup.HeaderDistance = 30.0f;//页眉位置
            //设置页眉
            wordApp.ActiveWindow.View.Type = Microsoft.Office.Interop.Word.WdViewType.wdOutlineView;//视图样式
            wordApp.ActiveWindow.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekPrimaryHeader;//进入页眉设置，其中页眉边距在页面设置中已完成
            wordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
            //插入页眉图片(测试结果图片未插入成功)(Paragraph段落格式Format格式Alignment对齐)
            //wordApp.Selection.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;
            //string headerfile = "d:\\1.jpg";
            //Microsoft.Office.Interop.Word.InlineShape shape1 = wordApp.ActiveWindow.ActivePane.Selection.InlineShapes.AddPicture(headerfile, ref Nothing, ref Nothing, ref Nothing);
            //shape1.Height = 20;
            //shape1.Width = 80;
            wordApp.ActiveWindow.ActivePane.Selection.InsertAfter("2015年观测资料汇编                                                                           滨海抽水站");
            wordApp.ActiveWindow.ActivePane.Selection.Font.Bold = 0;
            wordApp.ActiveWindow.ActivePane.Selection.Font.Name = "宋体";//页眉的字体
            //去掉页眉的横线
            wordApp.ActiveWindow.ActivePane.Selection.ParagraphFormat.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].LineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleSingle;
            wordApp.ActiveWindow.ActivePane.Selection.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].Visible = false;
            wordApp.ActiveWindow.ActivePane.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekMainDocument;//退出页眉设置
            //为当前页添加页码
            Microsoft.Office.Interop.Word.PageNumbers pns = wordApp.Selection.Sections[1].Headers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterEvenPages].PageNumbers;//获取当前页的号码
            pns.NumberStyle = Microsoft.Office.Interop.Word.WdPageNumberStyle.wdPageNumberStyleNumberInDash;
            pns.HeadingLevelForChapter = 0;
            pns.IncludeChapterNumber = false;
            pns.RestartNumberingAtSection = false;
            pns.StartingNumber = 0;
            object pagenmbetal = Microsoft.Office.Interop.Word.WdPageNumberAlignment.wdAlignPageNumberCenter;//将号码设置在中间
            object first = true;
            wordApp.Selection.Sections[1].Footers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterEvenPages].PageNumbers.Add(ref pagenmbetal, ref first);



            CZWYGCB(unite, Nothing, wordApp, wordDoc);

            //关闭保存word
            object format = MSWord.WdSaveFormat.wdFormatDocument;
            wordDoc.SaveAs(ref path, ref format, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);
            wordDoc.Close(ref Nothing, ref Nothing, ref Nothing);
            wordApp.Quit(ref Nothing, ref Nothing, ref Nothing); //关闭wordApp组件对象
            //Response.Write("<script>alert('" + path + ": Word文档格式设置完毕!');</script>");
            MessageBox.Show("操作完成");
        }
        /// <summary>
        /// 工作说明写标题
        /// </summary>
        /// <param name="Nothing"></param>
        /// <param name="str">文本</param>
        public void CreatWorkExplian1(object unite, object Nothing, string str, MSWord.Application wordApp, MSWord.Document wordDoc)
        {
            //工作说明写标题

            wordApp.Selection.EndKey(ref unite, ref Nothing); //将光标移动到文档末尾
            //wordApp.Selection.ParagraphFormat.FirstLineIndent = 10;//取消首行缩进的长度
            strContent = "滨海抽水站2015年观测工作说明\n\n ";//在文本中使用'\n'换行
            wordDoc.Paragraphs.Last.Range.Font.Name = "宋体";
            wordDoc.Paragraphs.Last.Range.Font.Size = 25;
            wordDoc.Paragraphs.Last.Range.Font.Bold = 1;//Bold=0为不加粗
            wordDoc.Paragraphs.Last.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
            wordDoc.Paragraphs.Last.Range.Text = strContent;
            // wordApp.Selection.Text = strContent;
            //写正文
            wordApp.Selection.EndKey(ref unite, ref Nothing); //将光标移动到文档末尾
            wordApp.Selection.ParagraphFormat.FirstLineIndent = 50;//取消首行缩进的长度
            strContent = str;//在文本中使用'\n'换行
            wordDoc.Paragraphs.Last.Range.Font.Name = "宋体";
            wordDoc.Paragraphs.Last.Range.Font.Size = 15;
            wordDoc.Paragraphs.Last.Range.Font.Bold = 0;//Bold=0为不加粗
            wordDoc.Paragraphs.Last.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;
            wordDoc.Paragraphs.Last.Range.Text = strContent;
            // wordApp.Selection.Text = strContent;
        }

        /// <summary>
        /// 插入各种图片
        /// </summary>
        /// <param name="Nothing"></param>
        public void InsertPicture(object Nothing, MSWord.Application wordApp, MSWord.Document wordDoc)
        {
            //换页
            object mymissing = System.Reflection.Missing.Value;
            object myunit = Microsoft.Office.Interop.Word.WdUnits.wdStory;
            wordApp.Selection.EndKey(ref myunit, ref mymissing); //将光标移动到文档末尾
            object pBreak = (int)Microsoft.Office.Interop.Word.WdBreakType.wdPageBreak;
            wordApp.Selection.InsertBreak(ref pBreak);
            //插入观测线路示意图
            string filename = "d:\\CAD.jpg";
            //定义要向文档中插入图片的位置
            object range = wordDoc.Paragraphs.Last.Range;
            //定义该图片是否为外部链接
            object linkToFile = false;//默认
            //定义插入的图片是否随word一起保存
            object saveWithDocument = true;
            //向word中写入图片
            wordDoc.InlineShapes.AddPicture(filename, ref Nothing, ref Nothing, ref Nothing);
            wordApp.Selection.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;//居中显示图片
            wordDoc.InlineShapes[1].Height = 620;
            wordDoc.InlineShapes[1].Width = 400;
            //按比例缩放大小 
            //wordDoc.InlineShapes[1].ScaleWidth = 20;//缩小到20% ？
            //wordDoc.InlineShapes[1].ScaleHeight = 20;
            ////将图片设置为四周环绕型  
            //WdWrapType wdWrapType;
            //wdWrapType = Microsoft.Office.Interop.Word.WdWrapType.wdWrapSquare;
            //Microsoft.Office.Interop.Word.Shape s = wordDoc.Application.ActiveDocument.InlineShapes[1].ConvertToShape();
            //s.WrapFormat.Type = wdWrapType;           
            ////图片下插入文字
            //wordDoc.Content.InsertAfter("\n");
            //wordApp.Selection.EndKey(ref unite, ref Nothing);
            //wordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
            //wordApp.Selection.Font.Size = 10;//字体大小
            //wordApp.Selection.TypeText("图1 测试图片\n");

        }

        /// <summary>
        /// 垂直位移观测表（旧）
        /// </summary>
        /// <param name="unite"></param>
        /// <param name="Nothing"></param>
        public void CZWYGCB_old(object unite, object Nothing, MSWord.Application wordApp, MSWord.Document wordDoc, string str, string Timer1)
        {
            int a = wordDoc.Characters.Count;
            object mymissing = System.Reflection.Missing.Value;
            object myunit = Microsoft.Office.Interop.Word.WdUnits.wdStory;
            //object myextend = Microsoft.Office.Interop.Word.wd
            object pBreak = (int)Microsoft.Office.Interop.Word.WdBreakType.wdPageBreak;
            //换页
            wordApp.Selection.EndKey(ref myunit, ref mymissing);
            //wordApp.Selection.InsertBreak(ref pBreak);
            //wordDoc.PageSetup.Orientation = Microsoft.Office.Interop.Word.WdOrientation.wdOrientLandscape;
            //object unite = Microsoft.Office.Interop.Word.WdUnits.wdStory;
            //wordApp.Selection.EndKey(ref unite, ref Nothing);
            //wordApp.Selection.ParagraphFormat.FirstLineIndent = 10;//取消首行缩进的长度
            strContent = "滨海抽水站垂直位移观测成果表（旧）\n ";//在文本中使用'\n'换行
            wordDoc.Paragraphs.Last.Range.Font.Name = "宋体";
            wordDoc.Paragraphs.Last.Range.Font.Size = 20;
            wordDoc.Paragraphs.Last.Range.Font.Bold = 1;//Bold=0为不加粗
            wordDoc.Paragraphs.Last.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
            wordDoc.Paragraphs.Last.Range.Text = strContent;
            wordApp.Selection.EndKey(ref unite, ref Nothing);


            string SQL = "select CdPosition,CdId,Hit from result_observe where BreakName='" + str + "'and ObserDate='" + Timer1 + "'order by CdPosition";
            System.Data.DataTable Dt = GetDataTable(SQL);
            int tableRow = Dt.Rows.Count + 4; ;
            int tableColumn = 8;
            //定义一个word中的表格对象
            MSWord.Table table = wordDoc.Tables.Add(wordApp.Selection.Range, tableRow, tableColumn, ref Nothing, ref Nothing);
            //绑定数据
            string sql1 = "select distinct ObserDate from result_observe where BreakName='" + str + "'order by ObserDate desc";
            System.Data.DataTable dt1 = GetDataTable(sql1);
            for (int i = 0; i < dt1.Rows.Count; i++)
            {
                if (Convert.ToDateTime(Timer1) == Convert.ToDateTime(dt1.Rows[i][0]))
                {
                    //string sql = "select a.CdPosition ,a.CdId, a.Hit as Hit1 ,b.Hit as Hit2 ,c.Hit as Hit3 from result_observe a,(select CdPosition, CdId,Hit from result_observe where BreakName='" + str + "' and ObserDate = '" + Timer2 + "') b,(select CdPosition, CdId,Hit from result_observe where BreakName='" + str + "'and ObserDate ='" + Timer3 + "') c where BreakName='" + str + "'and a.ObserDate ='" + Timer1 + "'and a.CdId=b.CdId and b.CdId=c.CdId and a.CdPosition=b.CdPosition and b.CdPosition=c.CdPosition";
                    string sql = "select a.CdPosition ,a.CdId, a.Hit as Hit1 ,b.Hit as Hit2 ,c.Hit as Hit3 from result_observe a,(select CdPosition, CdId,Hit from result_observe where BreakName='" + str + "'and ObserDate ='" + Convert.ToDateTime(dt1.Rows[i + 1]["ObserDate"]).ToString("yyyy-MM-dd") + "') b,(select CdPosition, CdId,Hit from result_observe where BreakName='" + str + "'and ObserDate ='" + (Convert.ToDateTime(dt1.Rows[i]["ObserDate"])).ToString("yyyy-MM-dd") + "') c where BreakName='" + str + "'and a.ObserDate ='" + Convert.ToDateTime(dt1.Rows[dt1.Rows.Count - 1]["ObserDate"]).ToString("yyyy-MM-dd") + "' and a.CdId=b.CdId and b.CdId=c.CdId and a.CdPosition=b.CdPosition and b.CdPosition=c.CdPosition";
                    System.Data.DataTable dt = GetDataTable(sql);


                    //表格的索引是从1开始的
                    table.Cell(1, 1).Range.Text = "始测日期";
                    table.Cell(1, 3).Range.Text = Convert.ToDateTime(dt1.Rows[dt1.Rows.Count - 1]["ObserDate"]).ToString("yyyy年MM年dd");
                    table.Cell(1, 4).Range.Text = "上次观测日期";
                    table.Cell(1, 5).Range.Text = Convert.ToDateTime(dt1.Rows[i + 1]["ObserDate"]).ToString("yyyy年MM年dd");
                    table.Cell(1, 6).Range.Text = "本次观测日期";
                    table.Cell(1, 7).Range.Text = Timer1;
                    TimeSpan t = Convert.ToDateTime(Timer1) - Convert.ToDateTime(dt1.Rows[i + 1]["ObserDate"]);
                    int days = t.Days;
                    table.Cell(1, 8).Range.Text = "间隔" + days + "天";
                    table.Cell(2, 1).Range.Text = "测点";
                    table.Cell(2, 3).Range.Text = "始测高程（米）";
                    table.Cell(2, 4).Range.Text = "上次观测高程（米）";
                    table.Cell(2, 5).Range.Text = "本次观测高程（米）";
                    table.Cell(2, 6).Range.Text = "间隔位移量（毫米）";
                    table.Cell(2, 7).Range.Text = "累计位移量（毫米）";
                    table.Cell(2, 8).Range.Text = "备注";
                    table.Cell(3, 1).Range.Text = "部位";
                    table.Cell(3, 2).Range.Text = "编号";

                    for (int r = 4; r < tableRow; r++)
                    {
                        for (int j = 0; j < 2; j++)
                        {
                            table.Cell(r, j + 1).Range.Text = (string)dt.Rows[r - 4][j];
                        }
                        for (int j = 2; j < 5; j++)
                        {
                            table.Cell(r, j + 1).Range.Text = dt.Rows[r - 4][j].ToString();
                        }
                        table.Cell(r, 6).Range.Text = (Math.Round(((double)dt.Rows[r - 4][4] - (double)dt.Rows[r - 4][3]) * 1000, 1)).ToString();
                        table.Cell(r, 7).Range.Text = (Math.Round(((double)dt.Rows[r - 4][4] - (double)dt.Rows[r - 4][2]) * 1000, 1)).ToString();

                    }
                }
            }





            //for (int i = 1; i < tableRow; i++)
            //{
            //    for (int j = 1; j < tableColumn; j++)
            //    {
            //        if (i == 1)
            //        {
            //            table.Cell(i, j + 1).Range.Text = "Column " + j;
            //        }
            //        if (j == 1)
            //        {
            //            table.Cell(i + 1, j).Range.Text = "Row " + i;
            //        }
            //        table.Cell(i + 1, j + 1).Range.Text = i + "行 " + j + "列";
            //    }
            //}
            //添加行
            table.Rows.Add(ref Nothing);
            table.Rows[tableRow + 1].Height = 45;
            //设置table样式
            table.Rows.HeightRule = MSWord.WdRowHeightRule.wdRowHeightAtLeast;//列高度至少会是指定的最小值。
            table.Rows.Height = wordApp.CentimetersToPoints(float.Parse("0.8"));//将计量单位从厘米转换为磅（一磅等于 0.035 厘米）

            table.Range.Font.Size = 10.5F;
            table.Range.Font.Bold = 0;
            table.Rows.Alignment = WdRowAlignment.wdAlignRowCenter;//表格居中
            table.Range.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;//表格文本居中
            table.Range.Cells.VerticalAlignment = MSWord.WdCellVerticalAlignment.wdCellAlignVerticalCenter;//文本垂直贴到底部
            //设置table边框样式
            table.Borders.OutsideLineStyle = MSWord.WdLineStyle.wdLineStyleSingle;
            table.Borders.InsideLineStyle = MSWord.WdLineStyle.wdLineStyleSingle;

            //table.Rows[1].Range.Font.Bold = 0;
            //table.Rows[1].Range.Font.Size = 12F;
            //table.Cell(1, 1).Range.Font.Size = 10.5F;
            wordApp.Selection.Cells.Height = 40;//所有单元格的高度
            //除第一行外，其他行的行高都设置为20
            for (int i = 2; i <= tableRow; i++)
            {
                table.Rows[i].Height = 20;
            }
            //将表格左上角的单元格里的文字（“行” 和 “列”）居右
            //table.Cell(1, 1).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphRight;
            //将表格左上角的单元格里面下面的“列”字移到左边，相比上一行就是将ParagraphFormat改成了Paragraphs[2].Format
            //table.Cell(1, 1).Range.Paragraphs[2].Format.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;

            table.Columns[1].Width = 60;//将第 1列宽度设置为50
            table.Columns[2].Width = 40;
            //将其他列的宽度都设置为75
            for (int i = 3; i <= tableColumn - 1; i++)
            {
                table.Columns[i].Width = 60;
            }
            table.Columns[tableColumn].Width = 75;


            //添加表头斜线,并设置表头的样式
            //table.Cell(1, 1).Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderDiagonalDown].Visible = true;
            //table.Cell(1, 1).Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderDiagonalDown].Color = Microsoft.Office.Interop.Word.WdColor.wdColorGray60;
            //table.Cell(1, 1).Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderDiagonalDown].LineWidth = Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt;

            //表格边框
            //表格内容行边框
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderHorizontal, Microsoft.Office.Interop.Word.WdColor.wdColorGray20, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth025pt);
            //表格内容列边框
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderVertical, Microsoft.Office.Interop.Word.WdColor.wdColorGray20, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth025pt);
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderLeft, Microsoft.Office.Interop.Word.WdColor.wdColorGray50, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt);
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderRight, Microsoft.Office.Interop.Word.WdColor.wdColorGray50, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt);
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderTop, Microsoft.Office.Interop.Word.WdColor.wdColorGray50, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt);
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom, Microsoft.Office.Interop.Word.WdColor.wdColorGray50, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt);
            //合并单元格
            table.Cell(1, 1).Merge(table.Cell(1, 2));//横向合并
            table.Cell(2, 1).Merge(table.Cell(2, 2));
            table.Cell(2, 2).Merge(table.Cell(3, 3));//纵向合并
            table.Cell(2, 3).Merge(table.Cell(3, 4));
            table.Cell(2, 4).Merge(table.Cell(3, 5));
            table.Cell(2, 5).Merge(table.Cell(3, 6));
            table.Cell(2, 6).Merge(table.Cell(3, 7));
            table.Cell(2, 7).Merge(table.Cell(3, 8));
        }

        /// <summary>
        /// 基点高程考证表
        /// </summary>
        /// <param name="unite"></param>
        /// <param name="Nothing"></param>
        /// <param name="wordApp"></param>
        /// <param name="wordDoc"></param>
        public void JDGCKZB(object unite, object Nothing, MSWord.Application wordApp, MSWord.Document wordDoc, string Timer1, string Timer2, string Timer3)
        {
            //基点高程考证表
            //wordDoc.PageSetup.Orientation = Microsoft.Office.Interop.Word.WdOrientation.wdOrientLandscape;
            //object unite = Microsoft.Office.Interop.Word.WdUnits.wdStory;
            //wordApp.Selection.EndKey(ref unite, ref Nothing);
            //wordApp.Selection.ParagraphFormat.FirstLineIndent = 10;//取消首行缩进的长度
            object mymissing = System.Reflection.Missing.Value;
            object myunit = Microsoft.Office.Interop.Word.WdUnits.wdStory;
            object pBreak = (int)Microsoft.Office.Interop.Word.WdBreakType.wdPageBreak;
            //换页
            wordApp.Selection.EndKey(ref myunit, ref mymissing);
            //wordApp.Selection.InsertBreak(ref pBreak);

            strContent = "滨海抽水站工作基点高程考证表\n ";//在文本中使用'\n'换行
            wordDoc.Paragraphs.Last.Range.Font.Name = "宋体";
            wordDoc.Paragraphs.Last.Range.Font.Size = 20;
            wordDoc.Paragraphs.Last.Range.Font.Bold = 1;//Bold=0为不加粗
            wordDoc.Paragraphs.Last.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
            wordDoc.Paragraphs.Last.Range.Text = strContent;
            wordApp.Selection.EndKey(ref unite, ref Nothing);
            //绑定数据
            string sql = "select a.JdId,a.JdConfirmDate,a.JdConfirmHit,b.JdConfirmDate as Date1,b.JdConfirmHit as Hit1 ,c.JdConfirmDate as Date2,c.JdConfirmHit as Hit2 from jd_confirm a,(select JdConfirmDate, JdConfirmHit,JdId from jd_confirm where JdConfirmDate ='" + Timer1 + "') b,(select JdConfirmDate,JdConfirmHit,JdId from jd_confirm where JdConfirmDate ='" + Timer2 + "') c where a.JdConfirmDate ='" + Timer3 + "'and a.JdId=b.JdId and b.JdId=c.JdId";
            //string sql = "select a.JdId,a.JdConfirmDate,a.JdConfirmHit,b.JdConfirmDate as Date1,b.JdConfirmHit as Hit1 ,c.JdConfirmDate as Date2,c.JdConfirmHit as Hit2 from jd_confirm a,(select JdConfirmDate, JdConfirmHit,JdId from jd_confirm where BrakeId='滨海抽水站'and JdConfirmDate ='2014年10月23日') b,(select JdConfirmDate,JdConfirmHit,JdId from jd_confirm where BrakeId='滨海抽水站'and JdConfirmDate ='2015年3月11日') c where BrakeId='滨海抽水站'and a.JdConfirmDate ='2011年3月11日'and a.JdId=b.JdId and b.JdId=c.JdId";
            System.Data.DataTable dt = GetDataTable(sql);

            //插入表
            int tableRow = 20;
            int tableColumn = 8;
            //定义一个word中的表格对象
            MSWord.Table table = wordDoc.Tables.Add(wordApp.Selection.Range, tableRow, tableColumn, ref Nothing, ref Nothing);
            //表格的索引是从1开始的
            table.Cell(1, 1).Range.Text = "基点编号";
            table.Cell(1, 2).Range.Text = "原始观测";
            table.Cell(1, 4).Range.Text = "上次观测";
            table.Cell(1, 6).Range.Text = "本次观测";
            table.Cell(1, 8).Range.Text = "备注";
            table.Cell(2, 2).Range.Text = "观测日期";
            table.Cell(2, 3).Range.Text = "高程";
            table.Cell(2, 4).Range.Text = "观测日期";
            table.Cell(2, 5).Range.Text = "高程";
            table.Cell(2, 6).Range.Text = "观测日期";
            table.Cell(2, 7).Range.Text = "高程";
            //3,5,7列是double型数据
            for (int i = 3; i < dt.Rows.Count + 3; i++)
            {
                for (int j = 0; j < 7; j++)
                {
                    if (j == 2 || j == 4 || j == 6)
                    {
                        table.Cell(i, j + 1).Range.Text = ((double)dt.Rows[i - 3][j]).ToString();

                    }
                    else
                    {
                        table.Cell(i, j + 1).Range.Text = (string)dt.Rows[i - 3][j];
                    }
                }

            }

            //添加行
            table.Rows.Add(ref Nothing);
            table.Rows[tableRow + 1].Height = 45;
            //设置table样式
            table.Rows.HeightRule = MSWord.WdRowHeightRule.wdRowHeightAtLeast;//列高度至少会是指定的最小值。
            table.Rows.Height = wordApp.CentimetersToPoints(float.Parse("0.8"));//将计量单位从厘米转换为磅（一磅等于 0.035 厘米）

            table.Range.Font.Size = 10.5F;
            table.Range.Font.Bold = 0;
            table.Rows.Alignment = WdRowAlignment.wdAlignRowCenter;//表格居中
            table.Range.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;//表格文本居中
            table.Range.Cells.VerticalAlignment = MSWord.WdCellVerticalAlignment.wdCellAlignVerticalCenter;//文本垂直贴到底部
            //设置table边框样式
            table.Borders.OutsideLineStyle = MSWord.WdLineStyle.wdLineStyleSingle;
            table.Borders.InsideLineStyle = MSWord.WdLineStyle.wdLineStyleSingle;

            //table.Rows[1].Range.Font.Bold = 0;
            //table.Rows[1].Range.Font.Size = 12F;
            //table.Cell(1, 1).Range.Font.Size = 10.5F;
            wordApp.Selection.Cells.Height = 20;//所有单元格的高度
            //除第一行外，其他行的行高都设置为20
            //for (int i = 2; i <= tableRow; i++)
            //{
            //    table.Rows[i].Height = 20;
            //}
            //将表格左上角的单元格里的文字（“行” 和 “列”）居右
            //table.Cell(1, 1).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphRight;
            //将表格左上角的单元格里面下面的“列”字移到左边，相比上一行就是将ParagraphFormat改成了Paragraphs[2].Format
            //table.Cell(1, 1).Range.Paragraphs[2].Format.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;

            //table.Columns[1].Width = 60;//将第 1列宽度设置为50
            // table.Columns[2].Width = 40;
            wordApp.Selection.Cells.Width = 108;
            //将其他列的宽度都设置为75
            for (int i = 1; i <= tableColumn; i++)
            {
                table.Columns[i].Width = 58;
                i++;
            }

            //添加表头斜线,并设置表头的样式
            //table.Cell(1, 1).Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderDiagonalDown].Visible = true;
            //table.Cell(1, 1).Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderDiagonalDown].Color = Microsoft.Office.Interop.Word.WdColor.wdColorGray60;
            //table.Cell(1, 1).Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderDiagonalDown].LineWidth = Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt;

            //表格边框
            //表格内容行边框
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderHorizontal, Microsoft.Office.Interop.Word.WdColor.wdColorGray20, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth025pt);
            //表格内容列边框
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderVertical, Microsoft.Office.Interop.Word.WdColor.wdColorGray20, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth025pt);
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderLeft, Microsoft.Office.Interop.Word.WdColor.wdColorGray50, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt);
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderRight, Microsoft.Office.Interop.Word.WdColor.wdColorGray50, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt);
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderTop, Microsoft.Office.Interop.Word.WdColor.wdColorGray50, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt);
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom, Microsoft.Office.Interop.Word.WdColor.wdColorGray50, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt);
            //合并单元格
            table.Cell(1, 2).Merge(table.Cell(1, 3));//横向合并
            table.Cell(1, 3).Merge(table.Cell(1, 4));//横向合并
            table.Cell(1, 4).Merge(table.Cell(1, 5));//横向合并
            table.Cell(1, 1).Merge(table.Cell(2, 1));//纵向合并

        }

        /// <summary>
        /// 河床断面桩顶高程考证表
        /// </summary>
        /// <param name="unite"></param>
        /// <param name="Nothing"></param>
        /// <param name="wordApp"></param>
        /// <param name="wordDoc"></param>
        public void HCDMCLCGB(object unite, object Nothing, MSWord.Application wordApp, MSWord.Document wordDoc)
        {
            //wordDoc.PageSetup.Orientation = Microsoft.Office.Interop.Word.WdOrientation.wdOrientLandscape;
            //object unite = Microsoft.Office.Interop.Word.WdUnits.wdStory;
            //wordApp.Selection.EndKey(ref unite, ref Nothing);
            //wordApp.Selection.ParagraphFormat.FirstLineIndent = 10;//取消首行缩进的长度
            object mymissing = System.Reflection.Missing.Value;
            object myunit = Microsoft.Office.Interop.Word.WdUnits.wdStory;
            object pBreak = (int)Microsoft.Office.Interop.Word.WdBreakType.wdPageBreak;
            //换页
            wordApp.Selection.EndKey(ref myunit, ref mymissing);
            wordApp.Selection.InsertBreak(ref pBreak);

            strContent = "滨海抽水站河床断面桩顶高程考证表\n ";//在文本中使用'\n'换行
            wordDoc.Paragraphs.Last.Range.Font.Name = "宋体";
            wordDoc.Paragraphs.Last.Range.Font.Size = 20;
            wordDoc.Paragraphs.Last.Range.Font.Bold = 1;//Bold=0为不加粗
            wordDoc.Paragraphs.Last.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
            wordDoc.Paragraphs.Last.Range.Text = strContent;
            wordApp.Selection.EndKey(ref unite, ref Nothing);
            //插入表
            int tableRow = 20;
            int tableColumn = 9;
            //定义一个word中的表格对象
            MSWord.Table table = wordDoc.Tables.Add(wordApp.Selection.Range, tableRow, tableColumn, ref Nothing, ref Nothing);
            //表格的索引是从1开始的
            table.Cell(1, 1).Range.Text = "断面编号";
            table.Cell(1, 2).Range.Text = "里程桩号";
            table.Cell(1, 3).Range.Text = "位置";
            table.Cell(1, 4).Range.Text = "埋设日期";
            table.Cell(1, 5).Range.Text = "观测日期";
            table.Cell(1, 6).Range.Text = "桩顶高程（m）";
            table.Cell(1, 8).Range.Text = "断面宽m";
            table.Cell(1, 9).Range.Text = "备注";
            table.Cell(2, 6).Range.Text = "左岸";
            table.Cell(2, 7).Range.Text = "右岸";
            //for (int i = 1; i < tableRow; i++)
            //{
            //    for (int j = 1; j < tableColumn; j++)
            //    {
            //        if (i == 1)
            //        {
            //            table.Cell(i, j + 1).Range.Text = "Column " + j;
            //        }
            //        if (j == 1)
            //        {
            //            table.Cell(i + 1, j).Range.Text = "Row " + i;
            //        }
            //        table.Cell(i + 1, j + 1).Range.Text = i + "行 " + j + "列";
            //    }
            //}
            //添加行
            table.Rows.Add(ref Nothing);
            table.Rows[tableRow + 1].Height = 45;
            //设置table样式
            table.Rows.HeightRule = MSWord.WdRowHeightRule.wdRowHeightAtLeast;//列高度至少会是指定的最小值。
            table.Rows.Height = wordApp.CentimetersToPoints(float.Parse("0.8"));//将计量单位从厘米转换为磅（一磅等于 0.035 厘米）

            table.Range.Font.Size = 10.5F;
            table.Range.Font.Bold = 0;
            table.Rows.Alignment = WdRowAlignment.wdAlignRowCenter;//表格居中
            table.Range.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;//表格文本居中
            table.Range.Cells.VerticalAlignment = MSWord.WdCellVerticalAlignment.wdCellAlignVerticalCenter;//文本垂直贴到底部
            //设置table边框样式
            table.Borders.OutsideLineStyle = MSWord.WdLineStyle.wdLineStyleSingle;
            table.Borders.InsideLineStyle = MSWord.WdLineStyle.wdLineStyleSingle;

            //table.Rows[1].Range.Font.Bold = 0;
            //table.Rows[1].Range.Font.Size = 12F;
            //table.Cell(1, 1).Range.Font.Size = 10.5F;
            wordApp.Selection.Cells.Height = 20;//所有单元格的高度
            //除第一行外，其他行的行高都设置为20
            //for (int i = 2; i <= tableRow; i++)
            //{
            //    table.Rows[i].Height = 20;
            //}
            //将表格左上角的单元格里的文字（“行” 和 “列”）居右
            //table.Cell(1, 1).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphRight;
            //将表格左上角的单元格里面下面的“列”字移到左边，相比上一行就是将ParagraphFormat改成了Paragraphs[2].Format
            //table.Cell(1, 1).Range.Paragraphs[2].Format.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;

            //table.Columns[1].Width = 60;//将第 1列宽度设置为50
            // table.Columns[2].Width = 40;
            //wordApp.Selection.Cells.Width = 80;
            //将其他列的宽度都设置为75
            for (int i = 1; i <= 5; i++)
            {
                table.Columns[i].Width = 60;
            }
            for (int i = 6; i <= tableColumn; i++)
            {
                table.Columns[i].Width = 40;
            }

            //添加表头斜线,并设置表头的样式
            //table.Cell(1, 1).Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderDiagonalDown].Visible = true;
            //table.Cell(1, 1).Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderDiagonalDown].Color = Microsoft.Office.Interop.Word.WdColor.wdColorGray60;
            //table.Cell(1, 1).Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderDiagonalDown].LineWidth = Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt;

            //表格边框
            //表格内容行边框
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderHorizontal, Microsoft.Office.Interop.Word.WdColor.wdColorGray20, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth025pt);
            //表格内容列边框
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderVertical, Microsoft.Office.Interop.Word.WdColor.wdColorGray20, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth025pt);
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderLeft, Microsoft.Office.Interop.Word.WdColor.wdColorGray50, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt);
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderRight, Microsoft.Office.Interop.Word.WdColor.wdColorGray50, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt);
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderTop, Microsoft.Office.Interop.Word.WdColor.wdColorGray50, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt);
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom, Microsoft.Office.Interop.Word.WdColor.wdColorGray50, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt);
            //合并单元格
            table.Cell(1, 6).Merge(table.Cell(1, 7));//横向合并
            table.Cell(1, 1).Merge(table.Cell(2, 1));//纵向合并
            table.Cell(1, 2).Merge(table.Cell(2, 2));//纵向合并
            table.Cell(1, 3).Merge(table.Cell(2, 3));//纵向合并
            table.Cell(1, 4).Merge(table.Cell(2, 4));//纵向合并
            table.Cell(1, 5).Merge(table.Cell(2, 5));//纵向合并

        }

        /// <summary>
        /// 河床断面测量成果表
        /// </summary>
        /// <param name="unite"></param>
        /// <param name="Nothing"></param>
        /// <param name="wordApp"></param>
        /// <param name="wordDoc"></param>
        public void HCDMZDGCKZB(object unite, object Nothing, MSWord.Application wordApp, MSWord.Document wordDoc)
        {
            //wordDoc.PageSetup.Orientation = Microsoft.Office.Interop.Word.WdOrientation.wdOrientLandscape;
            //object unite = Microsoft.Office.Interop.Word.WdUnits.wdStory;
            //wordApp.Selection.EndKey(ref unite, ref Nothing);
            //wordApp.Selection.ParagraphFormat.FirstLineIndent = 10;//取消首行缩进的长度
            object mymissing = System.Reflection.Missing.Value;
            object myunit = Microsoft.Office.Interop.Word.WdUnits.wdStory;
            object pBreak = (int)Microsoft.Office.Interop.Word.WdBreakType.wdPageBreak;
            //换页
            wordApp.Selection.EndKey(ref myunit, ref mymissing);
            wordApp.Selection.InsertBreak(ref pBreak);

            strContent = "滨海抽水站河床断面测量成果表\n ";//在文本中使用'\n'换行
            wordDoc.Paragraphs.Last.Range.Font.Name = "宋体";
            wordDoc.Paragraphs.Last.Range.Font.Size = 20;
            wordDoc.Paragraphs.Last.Range.Font.Bold = 1;//Bold=0为不加粗
            wordDoc.Paragraphs.Last.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
            wordDoc.Paragraphs.Last.Range.Text = strContent;
            wordApp.Selection.EndKey(ref unite, ref Nothing);
            //插入表
            int tableRow = 22;
            int tableColumn = 9;
            //定义一个word中的表格对象
            MSWord.Table table = wordDoc.Tables.Add(wordApp.Selection.Range, tableRow, tableColumn, ref Nothing, ref Nothing);
            //这是插入的一个方法
            //object rownum = 1;
            //object colnum = 9;
            //table.Cell(1, 1).Split(ref rownum, ref colnum);
            //表格的索引是从1开始的
            table.Cell(2, 1).Range.Text = "点号";
            table.Cell(2, 2).Range.Text = "起点距（米）";
            table.Cell(2, 3).Range.Text = "高程（米）";
            table.Cell(2, 4).Range.Text = "点号";
            table.Cell(2, 5).Range.Text = "起点距（米）";
            table.Cell(2, 6).Range.Text = "高程（m）";
            table.Cell(2, 7).Range.Text = "点号";
            table.Cell(2, 8).Range.Text = "起点距（米）";
            table.Cell(2, 9).Range.Text = "高程（米）";
            //for (int i = 1; i < tableRow; i++)
            //{
            //    for (int j = 1; j < tableColumn; j++)
            //    {
            //        if (i == 1)
            //        {
            //            table.Cell(i, j + 1).Range.Text = "Column " + j;
            //        }
            //        if (j == 1)
            //        {
            //            table.Cell(i + 1, j).Range.Text = "Row " + i;
            //        }
            //        table.Cell(i + 1, j + 1).Range.Text = i + "行 " + j + "列";
            //    }
            //}
            //添加行
            table.Rows.Add(ref Nothing);
            table.Rows[tableRow + 1].Height = 45;
            //设置table样式
            table.Rows.HeightRule = MSWord.WdRowHeightRule.wdRowHeightAtLeast;//列高度至少会是指定的最小值。
            table.Rows.Height = wordApp.CentimetersToPoints(float.Parse("0.8"));//将计量单位从厘米转换为磅（一磅等于 0.035 厘米）

            table.Range.Font.Size = 10.5F;
            table.Range.Font.Bold = 0;
            table.Rows.Alignment = WdRowAlignment.wdAlignRowCenter;//表格居中
            table.Range.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;//表格文本居中
            table.Range.Cells.VerticalAlignment = MSWord.WdCellVerticalAlignment.wdCellAlignVerticalCenter;//文本垂直贴到底部
            //设置table边框样式
            table.Borders.OutsideLineStyle = MSWord.WdLineStyle.wdLineStyleSingle;
            table.Borders.InsideLineStyle = MSWord.WdLineStyle.wdLineStyleSingle;

            //table.Rows[1].Range.Font.Bold = 0;
            //table.Rows[1].Range.Font.Size = 12F;
            //table.Cell(1, 1).Range.Font.Size = 10.5F;
            wordApp.Selection.Cells.Height = 32;//所有单元格的高度
            //除第一行外，其他行的行高都设置为20
            for (int i = 3; i <= tableRow; i++)
            {
                table.Rows[i].Height = 24;
            }
            //将表格左上角的单元格里的文字（“行” 和 “列”）居右
            //table.Cell(1, 1).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphRight;
            //将表格左上角的单元格里面下面的“列”字移到左边，相比上一行就是将ParagraphFormat改成了Paragraphs[2].Format
            //table.Cell(1, 1).Range.Paragraphs[2].Format.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;

            //table.Columns[1].Width = 60;//将第 1列宽度设置为50
            // table.Columns[2].Width = 40;
            //wordApp.Selection.Cells.Width = 80;
            //将其他列的宽度都设置为75
            for (int i = 1; i <= 9; i++)
            {
                table.Columns[i].Width = 37;
                i = i + 2;
            }
            for (int i = 2; i <= 9; i++)
            {
                table.Columns[i].Width = 67;
                i = i + 2;
            }
            for (int i = 3; i <= 9; i++)
            {
                table.Columns[i].Width = 52;
                i = i + 2;
            }



            //添加表头斜线,并设置表头的样式
            //table.Cell(1, 1).Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderDiagonalDown].Visible = true;
            //table.Cell(1, 1).Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderDiagonalDown].Color = Microsoft.Office.Interop.Word.WdColor.wdColorGray60;
            //table.Cell(1, 1).Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderDiagonalDown].LineWidth = Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt;

            //表格边框
            //表格内容行边框
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderHorizontal, Microsoft.Office.Interop.Word.WdColor.wdColorGray20, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth025pt);
            //表格内容列边框
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderVertical, Microsoft.Office.Interop.Word.WdColor.wdColorGray20, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth025pt);
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderLeft, Microsoft.Office.Interop.Word.WdColor.wdColorGray50, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt);
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderRight, Microsoft.Office.Interop.Word.WdColor.wdColorGray50, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt);
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderTop, Microsoft.Office.Interop.Word.WdColor.wdColorGray50, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt);
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom, Microsoft.Office.Interop.Word.WdColor.wdColorGray50, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt);
            //合并单元格
            table.Cell(1, 2).Merge(table.Cell(1, 3));//横向合并
            table.Cell(1, 4).Merge(table.Cell(1, 5));//横向合并
            table.Cell(1, 6).Merge(table.Cell(1, 7));//横向合并

            table.Cell(1, 1).Width = 68;
            table.Cell(1, 2).Width = 88;
            table.Cell(1, 3).Width = 68;
            table.Cell(1, 4).Width = 88;
            table.Cell(1, 5).Width = 68;
            table.Cell(1, 6).Width = 88;

            table.Cell(1, 1).Range.Text = "断面编号";
            table.Cell(1, 3).Range.Text = "里程桩号";
            table.Cell(1, 5).Range.Text = "测量日期";
            //写注释
            wordApp.Selection.EndKey(ref unite, ref Nothing); //将光标移动到文档末尾
            wordApp.Selection.ParagraphFormat.FirstLineIndent = 0;//取消首行缩进的长度
            strContent = "注：起点距从左岸断面桩起算，向右为正，向左为负。";//在文本中使用'\n'换行
            wordDoc.Paragraphs.Last.Range.Font.Name = "宋体";
            wordDoc.Paragraphs.Last.Range.Font.Size = 10;
            wordDoc.Paragraphs.Last.Range.Font.Bold = 0;//Bold=0为不加粗
            wordDoc.Paragraphs.Last.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;
            wordDoc.Paragraphs.Last.Range.Text = strContent;

        }



        /// <summary>
        /// 垂直位移工作基点考证表
        /// </summary>
        /// <param name="unite"></param>
        /// <param name="Nothing"></param>
        public void CZWYGZJDKZB(object unite, object Nothing, MSWord.Application wordApp, MSWord.Document wordDoc, string str1, string str2)
        {
            object mymissing = System.Reflection.Missing.Value;
            object myunit = Microsoft.Office.Interop.Word.WdUnits.wdStory;
            object pBreak = (int)Microsoft.Office.Interop.Word.WdBreakType.wdPageBreak;
            //换页
            wordApp.Selection.EndKey(ref myunit, ref mymissing);
            //wordApp.Selection.InsertBreak(ref pBreak);
            //wordDoc.PageSetup.Orientation = Microsoft.Office.Interop.Word.WdOrientation.wdOrientLandscape;
            //object unite = Microsoft.Office.Interop.Word.WdUnits.wdStory;
            //wordApp.Selection.EndKey(ref unite, ref Nothing);
            //wordApp.Selection.ParagraphFormat.FirstLineIndent = 10;//取消首行缩进的长度
            strContent = "垂直位移工作基点考证表\n ";//在文本中使用'\n'换行
            wordDoc.Paragraphs.Last.Range.Font.Name = "宋体";
            wordDoc.Paragraphs.Last.Range.Font.Size = 20;
            wordDoc.Paragraphs.Last.Range.Font.Bold = 1;//Bold=0为不加粗
            wordDoc.Paragraphs.Last.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
            wordDoc.Paragraphs.Last.Range.Text = strContent;
            wordApp.Selection.EndKey(ref unite, ref Nothing);
            //绑数据
            string sql = "select jd_info.JdId ,jd_info.JdMat,jd_info.JdDate,jd_info.JdPos ,jd_info.JdSit ,jd_confirm.JdConfirmDate ,jd_confirm.JdConfirmHit  from jd_info ,jd_confirm where jd_info.BrakeId = jd_confirm.BrakeId and jd_confirm.BrakeId='" + str1 + "'and jd_confirm.JdConfirmDate ='" + str2 + "'";
            System.Data.DataTable dt = GetDataTable(sql);


            //插入表
            int tableRow = dt.Rows.Count + 1;
            int tableColumn = 8;
            //定义一个word中的表格对象
            MSWord.Table table = wordDoc.Tables.Add(wordApp.Selection.Range, tableRow, tableColumn, ref Nothing, ref Nothing);
            //表格的索引是从1开始的
            table.Cell(1, 1).Range.Text = "基点编号";
            table.Cell(1, 2).Range.Text = "标点材料";
            table.Cell(1, 3).Range.Text = "埋设日期";
            table.Cell(1, 4).Range.Text = "位置";
            table.Cell(1, 5).Range.Text = "地基情况";
            table.Cell(1, 6).Range.Text = "考证日期";
            table.Cell(1, 7).Range.Text = "高程m";
            table.Cell(1, 8).Range.Text = "备注";
            table.Cell(15, 1).Range.Text = "标点位置及位置图";

            for (int i = 2; i < dt.Rows.Count + 2; i++)
            {
                for (int j = 0; j < 7; j++)
                {
                    if (j == 6)
                    {
                        table.Cell(i, j + 1).Range.Text = ((double)dt.Rows[i - 2][j]).ToString();
                    }
                    else
                    {
                        table.Cell(i, j + 1).Range.Text = ((string)dt.Rows[i - 2][j]);
                    }
                }
            }

            //添加行
            table.Rows.Add(ref Nothing);
            table.Rows[tableRow + 1].Height = 45;
            //设置table样式
            table.Rows.HeightRule = MSWord.WdRowHeightRule.wdRowHeightAtLeast;//列高度至少会是指定的最小值。
            table.Rows.Height = wordApp.CentimetersToPoints(float.Parse("0.8"));//将计量单位从厘米转换为磅（一磅等于 0.035 厘米）

            table.Range.Font.Size = 10.5F;
            table.Range.Font.Bold = 0;
            table.Rows.Alignment = WdRowAlignment.wdAlignRowCenter;//表格居中
            table.Range.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;//表格文本居中
            table.Range.Cells.VerticalAlignment = MSWord.WdCellVerticalAlignment.wdCellAlignVerticalCenter;//文本垂直贴到底部
            //设置table边框样式
            table.Borders.OutsideLineStyle = MSWord.WdLineStyle.wdLineStyleSingle;
            table.Borders.InsideLineStyle = MSWord.WdLineStyle.wdLineStyleSingle;

            //table.Rows[1].Range.Font.Bold = 0;
            //table.Rows[1].Range.Font.Size = 12F;
            //table.Cell(1, 1).Range.Font.Size = 10.5F;
            wordApp.Selection.Cells.Height = 25;//所有单元格的高度
            wordApp.Selection.Cells.Width = 55;
            //除第一行外，其他行的行高都设置为20
            //for (int i = 2; i <= tableRow; i++)
            //{
            //    table.Rows[i].Height = 20;
            //}
            //将表格左上角的单元格里的文字（“行” 和 “列”）居右
            //table.Cell(1, 1).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphRight;
            //将表格左上角的单元格里面下面的“列”字移到左边，相比上一行就是将ParagraphFormat改成了Paragraphs[2].Format
            //table.Cell(1, 1).Range.Paragraphs[2].Format.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;

            //table.Columns[1].Width = 60;//将第 1列宽度设置为50
            //table.Columns[2].Width = 40;
            ////将其他列的宽度都设置为75
            //for (int i = 3; i <= tableColumn - 1; i++)
            //{
            //    table.Columns[i].Width = 60;
            //}
            //table.Columns[tableColumn].Width = 75;


            //添加表头斜线,并设置表头的样式
            //table.Cell(1, 1).Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderDiagonalDown].Visible = true;
            //table.Cell(1, 1).Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderDiagonalDown].Color = Microsoft.Office.Interop.Word.WdColor.wdColorGray60;
            //table.Cell(1, 1).Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderDiagonalDown].LineWidth = Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt;

            //表格边框
            //表格内容行边框
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderHorizontal, Microsoft.Office.Interop.Word.WdColor.wdColorGray20, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth025pt);
            //表格内容列边框
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderVertical, Microsoft.Office.Interop.Word.WdColor.wdColorGray20, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth025pt);
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderLeft, Microsoft.Office.Interop.Word.WdColor.wdColorGray50, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt);
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderRight, Microsoft.Office.Interop.Word.WdColor.wdColorGray50, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt);
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderTop, Microsoft.Office.Interop.Word.WdColor.wdColorGray50, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt);
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom, Microsoft.Office.Interop.Word.WdColor.wdColorGray50, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt);
            //合并单元格
            table.Cell(15, 1).Merge(table.Cell(21, 8));//横向合并
        }
        /// <summary>
        /// 垂直位移观测记录表
        /// </summary>
        /// <param name="unite"></param>
        /// <param name="Nothing"></param> 
        public void CZWYGCB(object unite, object Nothing, MSWord.Application wordApp, MSWord.Document wordDoc)
        {
            object mymissing = System.Reflection.Missing.Value;
            object myunit = Microsoft.Office.Interop.Word.WdUnits.wdStory;
            object pBreak = (int)Microsoft.Office.Interop.Word.WdBreakType.wdPageBreak;
            //换页
            wordApp.Selection.EndKey(ref myunit, ref mymissing);
            wordApp.Selection.InsertBreak(ref pBreak);
            //wordDoc.PageSetup.Orientation = Microsoft.Office.Interop.Word.WdOrientation.wdOrientLandscape;
            //object unite = Microsoft.Office.Interop.Word.WdUnits.wdStory;
            //wordApp.Selection.EndKey(ref unite, ref Nothing);
            //wordApp.Selection.ParagraphFormat.FirstLineIndent = 10;//取消首行缩进的长度
            strContent = "垂直位移观测记录表\n ";//在文本中使用'\n'换行
            wordDoc.Paragraphs.Last.Range.Font.Name = "宋体";
            wordDoc.Paragraphs.Last.Range.Font.Size = 20;
            wordDoc.Paragraphs.Last.Range.Font.Bold = 1;//Bold=0为不加粗
            wordDoc.Paragraphs.Last.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
            wordDoc.Paragraphs.Last.Range.Text = strContent;
            wordApp.Selection.EndKey(ref unite, ref Nothing);
            //插入表
            int tableRow = 20;
            int tableColumn = 10;
            //定义一个word中的表格对象
            MSWord.Table table = wordDoc.Tables.Add(wordApp.Selection.Range, tableRow, tableColumn, ref Nothing, ref Nothing);
            //表格的索引是从1开始的
            table.Cell(1, 1).Range.Text = "测站";
            table.Cell(1, 2).Range.Text = "视准点";
            table.Cell(2, 2).Range.Text = "后视";
            table.Cell(3, 2).Range.Text = "前视";
            table.Cell(4, 2).Range.Text = "中视";
            table.Cell(1, 3).Range.Text = "视距读数";
            table.Cell(2, 3).Range.Text = "后距1";
            table.Cell(2, 4).Range.Text = "后距2";
            table.Cell(3, 3).Range.Text = "前距1";
            table.Cell(3, 4).Range.Text = "前距2";
            table.Cell(4, 3).Range.Text = "视距差(m)";
            table.Cell(4, 4).Range.Text = "累计差(m)";

            table.Cell(1, 5).Range.Text = "标尺读数";
            table.Cell(2, 5).Range.Text = "后尺读数1";
            table.Cell(2, 6).Range.Text = "后尺读数2";
            table.Cell(3, 5).Range.Text = "前尺读数1";
            table.Cell(3, 6).Range.Text = "前尺读数2";
            table.Cell(4, 5).Range.Text = "高差(m)";
            table.Cell(4, 6).Range.Text = "高差(m)";

            table.Cell(1, 7).Range.Text = "读数差(mm)";
            table.Cell(1, 8).Range.Text = "高差(m)";
            table.Cell(1, 9).Range.Text = "高程(m)";
            table.Cell(1, 10).Range.Text = "平差后高程(m)";


            //添加行
            table.Rows.Add(ref Nothing);
            table.Rows[tableRow + 1].Height = 45;
            //设置table样式
            table.Rows.HeightRule = MSWord.WdRowHeightRule.wdRowHeightAtLeast;//列高度至少会是指定的最小值。
            table.Rows.Height = wordApp.CentimetersToPoints(float.Parse("0.8"));//将计量单位从厘米转换为磅（一磅等于 0.035 厘米）

            table.Range.Font.Size = 12F;
            table.Range.Font.Bold = 0;
            table.Rows.Alignment = WdRowAlignment.wdAlignRowCenter;//表格居中
            table.Range.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;//表格文本居中
            table.Range.Cells.VerticalAlignment = MSWord.WdCellVerticalAlignment.wdCellAlignVerticalCenter;//文本垂直贴到底部
            //设置table边框样式
            table.Borders.OutsideLineStyle = MSWord.WdLineStyle.wdLineStyleSingle;
            table.Borders.InsideLineStyle = MSWord.WdLineStyle.wdLineStyleSingle;

            //table.Rows[1].Range.Font.Bold = 0;
            //table.Rows[1].Range.Font.Size = 12F;
            //table.Cell(1, 1).Range.Font.Size = 10.5F;
            wordApp.Selection.Cells.Height = 25;//所有单元格的高度
            //除第一行外，其他行的行高都设置为20
            table.Rows[2].Height = 40;
            //将表格左上角的单元格里的文字（“行” 和 “列”）居右
            //table.Cell(1, 1).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphRight;
            //将表格左上角的单元格里面下面的“列”字移到左边，相比上一行就是将ParagraphFormat改成了Paragraphs[2].Format
            //table.Cell(1, 1).Range.Paragraphs[2].Format.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
            //将其他列的宽度都设置为75
            for (int i = 1; i <= tableColumn - 1; i++)
            {
                table.Columns[i].Width = 60;
            }
            table.Columns[tableColumn].Width = 75;


            //添加表头斜线,并设置表头的样式
            //table.Cell(1, 1).Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderDiagonalDown].Visible = true;
            //table.Cell(1, 1).Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderDiagonalDown].Color = Microsoft.Office.Interop.Word.WdColor.wdColorGray60;
            //table.Cell(1, 1).Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderDiagonalDown].LineWidth = Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt;

            //表格边框
            //表格内容行边框
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderHorizontal, Microsoft.Office.Interop.Word.WdColor.wdColorGray20, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth025pt);
            //表格内容列边框
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderVertical, Microsoft.Office.Interop.Word.WdColor.wdColorGray20, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth025pt);
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderLeft, Microsoft.Office.Interop.Word.WdColor.wdColorGray50, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt);
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderRight, Microsoft.Office.Interop.Word.WdColor.wdColorGray50, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt);
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderTop, Microsoft.Office.Interop.Word.WdColor.wdColorGray50, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt);
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom, Microsoft.Office.Interop.Word.WdColor.wdColorGray50, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt);
            //合并单元格
            table.Cell(1, 1).Merge(table.Cell(4, 1));//纵向合并
            table.Cell(1, 7).Merge(table.Cell(4, 7));
            table.Cell(1, 8).Merge(table.Cell(4, 8));
            table.Cell(1, 9).Merge(table.Cell(4, 9));
            table.Cell(1, 10).Merge(table.Cell(4, 10));

            table.Cell(1, 3).Merge(table.Cell(1, 4));//横向合并
            table.Cell(1, 5).Merge(table.Cell(1, 6));


        }
        /// <summary>
        /// 垂直位移观测标点考证表
        /// </summary>
        /// <param name="unite"></param>
        /// <param name="Nothing"></param>
        public void CZWYGCBDKZB(object unite, object Nothing, MSWord.Application wordApp, MSWord.Document wordDoc)
        {
            object mymissing = System.Reflection.Missing.Value;
            object myunit = Microsoft.Office.Interop.Word.WdUnits.wdStory;
            object pBreak = (int)Microsoft.Office.Interop.Word.WdBreakType.wdPageBreak;
            //换页
            wordApp.Selection.EndKey(ref myunit, ref mymissing);
            wordApp.Selection.InsertBreak(ref pBreak);
            //wordDoc.PageSetup.Orientation = Microsoft.Office.Interop.Word.WdOrientation.wdOrientLandscape;
            //object unite = Microsoft.Office.Interop.Word.WdUnits.wdStory;
            //wordApp.Selection.EndKey(ref unite, ref Nothing);
            //wordApp.Selection.ParagraphFormat.FirstLineIndent = 10;//取消首行缩进的长度
            strContent = "垂直位移观测标点考证表\n ";//在文本中使用'\n'换行
            wordDoc.Paragraphs.Last.Range.Font.Name = "宋体";
            wordDoc.Paragraphs.Last.Range.Font.Size = 20;
            wordDoc.Paragraphs.Last.Range.Font.Bold = 1;//Bold=0为不加粗
            wordDoc.Paragraphs.Last.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
            wordDoc.Paragraphs.Last.Range.Text = strContent;
            wordApp.Selection.EndKey(ref unite, ref Nothing);
            //插入表
            int tableRow = 20;
            int tableColumn = 8;
            //定义一个word中的表格对象
            MSWord.Table table = wordDoc.Tables.Add(wordApp.Selection.Range, tableRow, tableColumn, ref Nothing, ref Nothing);
            //表格的索引是从1开始的
            table.Cell(1, 1).Range.Text = "标点";
            table.Cell(1, 3).Range.Text = "埋设日期";
            table.Cell(1, 4).Range.Text = "原始点（末次）";
            table.Cell(1, 6).Range.Text = "新标点";
            table.Cell(1, 8).Range.Text = "备注";
            table.Cell(2, 1).Range.Text = "部位";
            table.Cell(2, 2).Range.Text = "编号";
            table.Cell(2, 4).Range.Text = "观测日期";
            table.Cell(2, 5).Range.Text = "高程";
            table.Cell(2, 6).Range.Text = "考证日期";
            table.Cell(2, 7).Range.Text = "高程";
            //for (int i = 1; i < tableRow; i++)
            //{
            //    for (int j = 1; j < tableColumn; j++)
            //    {
            //        if (i == 1)
            //        {
            //            table.Cell(i, j + 1).Range.Text = "Column " + j;
            //        }
            //        if (j == 1)
            //        {
            //            table.Cell(i + 1, j).Range.Text = "Row " + i;
            //        }
            //        table.Cell(i + 1, j + 1).Range.Text = i + "行 " + j + "列";
            //    }
            //}
            //添加行
            table.Rows.Add(ref Nothing);
            table.Rows[tableRow + 1].Height = 45;
            //设置table样式
            table.Rows.HeightRule = MSWord.WdRowHeightRule.wdRowHeightAtLeast;//列高度至少会是指定的最小值。
            table.Rows.Height = wordApp.CentimetersToPoints(float.Parse("0.8"));//将计量单位从厘米转换为磅（一磅等于 0.035 厘米）

            table.Range.Font.Size = 12F;
            table.Range.Font.Bold = 0;
            table.Rows.Alignment = WdRowAlignment.wdAlignRowCenter;//表格居中
            table.Range.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;//表格文本居中
            table.Range.Cells.VerticalAlignment = MSWord.WdCellVerticalAlignment.wdCellAlignVerticalCenter;//文本垂直贴到底部
            //设置table边框样式
            table.Borders.OutsideLineStyle = MSWord.WdLineStyle.wdLineStyleSingle;
            table.Borders.InsideLineStyle = MSWord.WdLineStyle.wdLineStyleSingle;

            //table.Rows[1].Range.Font.Bold = 0;
            //table.Rows[1].Range.Font.Size = 12F;
            //table.Cell(1, 1).Range.Font.Size = 10.5F;
            wordApp.Selection.Cells.Height = 25;//所有单元格的高度
            //除第一行外，其他行的行高都设置为20
            table.Rows[2].Height = 40;
            //将表格左上角的单元格里的文字（“行” 和 “列”）居右
            //table.Cell(1, 1).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphRight;
            //将表格左上角的单元格里面下面的“列”字移到左边，相比上一行就是将ParagraphFormat改成了Paragraphs[2].Format
            //table.Cell(1, 1).Range.Paragraphs[2].Format.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
            //将其他列的宽度都设置为75
            for (int i = 1; i <= tableColumn - 1; i++)
            {
                table.Columns[i].Width = 60;
            }
            table.Columns[tableColumn].Width = 75;


            //添加表头斜线,并设置表头的样式
            //table.Cell(1, 1).Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderDiagonalDown].Visible = true;
            //table.Cell(1, 1).Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderDiagonalDown].Color = Microsoft.Office.Interop.Word.WdColor.wdColorGray60;
            //table.Cell(1, 1).Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderDiagonalDown].LineWidth = Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt;

            //表格边框
            //表格内容行边框
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderHorizontal, Microsoft.Office.Interop.Word.WdColor.wdColorGray20, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth025pt);
            //表格内容列边框
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderVertical, Microsoft.Office.Interop.Word.WdColor.wdColorGray20, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth025pt);
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderLeft, Microsoft.Office.Interop.Word.WdColor.wdColorGray50, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt);
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderRight, Microsoft.Office.Interop.Word.WdColor.wdColorGray50, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt);
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderTop, Microsoft.Office.Interop.Word.WdColor.wdColorGray50, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt);
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom, Microsoft.Office.Interop.Word.WdColor.wdColorGray50, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt);
            //合并单元格
            table.Cell(1, 1).Merge(table.Cell(1, 2));//横向合并
            table.Cell(1, 3).Merge(table.Cell(1, 4));
            table.Cell(1, 4).Merge(table.Cell(1, 5));
            table.Cell(1, 2).Merge(table.Cell(2, 3));//纵向合并
        }


        /// <summary>
        /// 垂直位移量变化统计表
        /// </summary>
        /// <param name="unite"></param>
        /// <param name="Nothing"></param>
        public void CZWYLBHTJB(object unite, object Nothing, MSWord.Application wordApp, MSWord.Document wordDoc, string str)
        {
            object mymissing = System.Reflection.Missing.Value;
            object myunit = Microsoft.Office.Interop.Word.WdUnits.wdStory;
            object pBreak = (int)Microsoft.Office.Interop.Word.WdBreakType.wdPageBreak;
            //换页
            wordApp.Selection.EndKey(ref myunit, ref mymissing);
            //wordApp.Selection.InsertBreak(ref pBreak);

            //绑定数据
            string sql = "select distinct ObserDate from result_observe where BreakName='" + str + "'order by ObserDate desc";//可以将获取的时间数据倒着赋值给一个容量为14的数组
            System.Data.DataTable dt = GetDataTable(sql);
            string[] str1 = new string[14];
            int a = dt.Rows.Count;
            for (int i = 0; i < 14; i++)
            {
                str1[i] = Convert.ToDateTime(dt.Rows[13 - i][0]).ToString("yyyy-MM-dd");
            }
            //获取前两列数据
            string SQL = "select CdPart,CdId from cd_info where BrakeId='" + str + "'order by CdPart";
            System.Data.DataTable dt1 = GetDataTable(SQL);
            DataSet ds = new DataSet();

            //获取累计位移量
            string[] sql2 = new string[14];
            for (int i = 0; i < 14; i++)
            {

                sql2[i] = "select Ljwyl as '" + (i + 1) + "'from LJWYL where BreakName='" + str + "'and ObserDate='" + str1[i] + "'";
                // System.Data.DataTable dt2 = GetDataTable(sql2);
                // ds = DbHelperSQL.Query(sql2[i]);
            }
            System.Data.DataTable dt2 = DbHelperSQL.GetDataTable(sql2[0]);
            System.Data.DataTable dt3 = DbHelperSQL.GetDataTable(sql2[1]);
            System.Data.DataTable dt4 = DbHelperSQL.GetDataTable(sql2[2]);
            System.Data.DataTable dt5 = DbHelperSQL.GetDataTable(sql2[3]);
            System.Data.DataTable dt6 = DbHelperSQL.GetDataTable(sql2[4]);
            System.Data.DataTable dt7 = DbHelperSQL.GetDataTable(sql2[5]);
            System.Data.DataTable dt8 = DbHelperSQL.GetDataTable(sql2[6]);
            System.Data.DataTable dt9 = DbHelperSQL.GetDataTable(sql2[7]);
            System.Data.DataTable dt10 = DbHelperSQL.GetDataTable(sql2[8]);
            System.Data.DataTable dt11 = DbHelperSQL.GetDataTable(sql2[9]);
            System.Data.DataTable dt12 = DbHelperSQL.GetDataTable(sql2[10]);
            System.Data.DataTable dt13 = DbHelperSQL.GetDataTable(sql2[11]);
            System.Data.DataTable dt14 = DbHelperSQL.GetDataTable(sql2[12]);
            System.Data.DataTable dt15 = DbHelperSQL.GetDataTable(sql2[13]);
            //for (int i = 0; i < 14; i++)
            //{
            //     dt1.Columns.Add("i");
            //}  
            //dt2.Columns.Add("1");
            //dt2.Columns.Add("1");
            dt2.Columns.Add("2");
            dt2.Columns.Add("3");
            dt2.Columns.Add("4");
            dt2.Columns.Add("5");
            dt2.Columns.Add("6");
            dt2.Columns.Add("7");
            dt2.Columns.Add("8");
            dt2.Columns.Add("9");
            dt2.Columns.Add("10");
            dt2.Columns.Add("11");
            dt2.Columns.Add("12");
            dt2.Columns.Add("13");
            dt2.Columns.Add("14");

            for (int i = 0; i < dt2.Rows.Count; i++)
            {

                dt2.Rows[i]["2"] = dt3.Rows[i]["2"];
                dt2.Rows[i]["3"] = dt4.Rows[i]["3"];
                dt2.Rows[i]["4"] = dt5.Rows[i]["4"];
                dt2.Rows[i]["5"] = dt6.Rows[i]["5"];
                dt2.Rows[i]["6"] = dt7.Rows[i]["6"];
                dt2.Rows[i]["7"] = dt8.Rows[i]["7"];
                dt2.Rows[i]["8"] = dt9.Rows[i]["8"];
                dt2.Rows[i]["9"] = dt10.Rows[i]["9"];
                dt2.Rows[i]["10"] = dt11.Rows[i]["10"];
                dt2.Rows[i]["11"] = dt12.Rows[i]["11"];
                dt2.Rows[i]["12"] = dt13.Rows[i]["12"];
                dt2.Rows[i]["13"] = dt14.Rows[i]["13"];
                dt2.Rows[i]["14"] = dt15.Rows[i]["14"];


            }

            //生成横版
            Object oMissing = System.Reflection.Missing.Value;
            object WdLine = Microsoft.Office.Interop.Word.WdUnits.wdParagraph;
            object oPageBreak = Microsoft.Office.Interop.Word.WdBreakType.wdSectionBreakNextPage;//分页符
            wordApp.Selection.InsertBreak(ref oPageBreak);
            wordApp.Selection.MoveDown(WdLine, 2, oMissing);
            wordApp.Selection.InsertBreak(ref oPageBreak);
            wordApp.Selection.MoveUp(WdLine, 1, oMissing);
            wordApp.Selection.PageSetup.Orientation = Microsoft.Office.Interop.Word.WdOrientation.wdOrientLandscape;

            int tableRow = dt1.Rows.Count + 3;
            int tableColumn = 16;
            //定义一个word中的表格对象
            MSWord.Table table = wordDoc.Tables.Add(wordApp.Selection.Range, tableRow, tableColumn, ref Nothing, ref Nothing);
            //表格的索引是从1开始的
            table.Cell(1, 1).Range.Text = "滨海抽水站垂直位移量变化统计表";
            table.Cell(2, 1).Range.Text = "测点";
            table.Cell(2, 3).Range.Text = "累计位移量(mm)";
            table.Cell(3, 1).Range.Text = "部位";
            table.Cell(3, 2).Range.Text = "编号";
            for (int i = 3; i < 17; i++)
            {
                table.Cell(3, i).Range.Text = str1[i - 3];
            }

            //写入前两列数据
            for (int i = 4; i < dt1.Rows.Count + 4; i++)//行
            {
                for (int j = 0; j < 2; j++)//列
                {
                    table.Cell(i, j + 1).Range.Text = ((string)dt1.Rows[i - 4][j]);

                }
            }
            //写入累计位移量
            for (int i = 4; i < dt2.Rows.Count + 4; i++)//行
            {
                for (int j = 0; j < 14; j++)
                {
                    table.Cell(i, j + 3).Range.Text = (Convert.ToDouble(dt2.Rows[i - 4][j])).ToString();

                }
            }
            //添加行
            table.Rows.Add(ref Nothing);
            table.Rows[tableRow + 1].Height = 45;
            //设置table样式
            table.Rows.HeightRule = MSWord.WdRowHeightRule.wdRowHeightAtLeast;//列高度至少会是指定的最小值。
            table.Rows.Height = wordApp.CentimetersToPoints(float.Parse("0.8"));//将计量单位从厘米转换为磅（一磅等于 0.035 厘米）

            table.Range.Font.Size = 10.5F;
            table.Range.Font.Bold = 0;
            table.Rows.Alignment = WdRowAlignment.wdAlignRowCenter;//表格居中
            table.Range.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;//表格文本居中
            table.Range.Cells.VerticalAlignment = MSWord.WdCellVerticalAlignment.wdCellAlignVerticalCenter;//文本垂直贴到底部
            //设置table边框样式
            table.Borders.OutsideLineStyle = MSWord.WdLineStyle.wdLineStyleSingle;
            table.Borders.InsideLineStyle = MSWord.WdLineStyle.wdLineStyleSingle;

            //table.Rows[1].Range.Font.Bold = 0;
            //table.Rows[1].Range.Font.Size = 12F;
            //table.Cell(1, 1).Range.Font.Size = 10.5F;
            wordApp.Selection.Cells.Height = 20;//所有单元格的高度
            //除第一行外，其他行的行高都设置为20
            table.Rows[1].Height = 70;
            table.Rows[2].Height = 45;
            table.Rows[3].Height = 70;
            //将表格左上角的单元格里的文字（“行” 和 “列”）居右
            //table.Cell(1, 1).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphRight;
            //将表格左上角的单元格里面下面的“列”字移到左边，相比上一行就是将ParagraphFormat改成了Paragraphs[2].Format
            //table.Cell(1, 1).Range.Paragraphs[2].Format.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;

            table.Columns[1].Width = 60;//将第 1列宽度设置为50
            table.Columns[2].Width = 35;
            //将其他列的宽度都设置为75
            for (int i = 3; i <= tableColumn; i++)
            {
                table.Columns[i].Width = 45;
            }


            table.Cell(1, 1).Range.Font.Size = 25F;
            //添加表头斜线,并设置表头的样式
            //table.Cell(1, 1).Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderDiagonalDown].Visible = true;
            //table.Cell(1, 1).Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderDiagonalDown].Color = Microsoft.Office.Interop.Word.WdColor.wdColorGray60;
            //table.Cell(1, 1).Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderDiagonalDown].LineWidth = Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt;

            //表格边框
            //表格内容行边框
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderHorizontal, Microsoft.Office.Interop.Word.WdColor.wdColorGray20, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth025pt);
            //表格内容列边框
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderVertical, Microsoft.Office.Interop.Word.WdColor.wdColorGray20, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth025pt);
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderLeft, Microsoft.Office.Interop.Word.WdColor.wdColorGray50, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt);
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderRight, Microsoft.Office.Interop.Word.WdColor.wdColorGray50, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt);
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderTop, Microsoft.Office.Interop.Word.WdColor.wdColorGray50, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt);
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom, Microsoft.Office.Interop.Word.WdColor.wdColorGray50, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt);
            //合并单元格
            table.Cell(1, 1).Merge(table.Cell(1, 16));//横向合并
            table.Cell(2, 1).Merge(table.Cell(2, 2));
            table.Cell(2, 2).Merge(table.Cell(2, 15));

            MSWord.WdStatistic stat = MSWord.WdStatistic.wdStatisticPages;
            int num = wordDoc.ComputeStatistics(stat, ref  Nothing);
        }


        /// <summary>
        /// 河床断面冲淤量比较表
        /// </summary>
        /// <param name="unite"></param>
        /// <param name="Nothing"></param>
        public void HCDMCYLBJB(object unite, object Nothing, MSWord.Application wordApp, MSWord.Document wordDoc)
        {
            int a = wordDoc.Characters.Count;
            object mymissing = System.Reflection.Missing.Value;
            object myunit = Microsoft.Office.Interop.Word.WdUnits.wdStory;
            //object myextend = Microsoft.Office.Interop.Word.wd
            object pBreak = (int)Microsoft.Office.Interop.Word.WdBreakType.wdPageBreak;
            //换页
            wordApp.Selection.EndKey(ref myunit, ref mymissing);
            //wordApp.Selection.InsertBreak(ref pBreak);
            //wordDoc.PageSetup.Orientation = Microsoft.Office.Interop.Word.WdOrientation.wdOrientLandscape;
            //object unite = Microsoft.Office.Interop.Word.WdUnits.wdStory;
            //wordApp.Selection.EndKey(ref unite, ref Nothing);
            //wordApp.Selection.ParagraphFormat.FirstLineIndent = 10;//取消首行缩进的长度
            //strContent = "滨海抽水站河床断面冲淤量比较表\n ";//在文本中使用'\n'换行
            //wordDoc.Paragraphs.Last.Range.Font.Name = "宋体";
            //wordDoc.Paragraphs.Last.Range.Font.Size = 18;
            //wordDoc.Paragraphs.Last.Range.Font.Bold = 0;//Bold=0为不加粗
            //wordDoc.Paragraphs.Last.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
            //wordDoc.Paragraphs.Last.Range.Text = strContent;
            //wordApp.Selection.EndKey(ref unite, ref Nothing);


            //生成横版
            Object oMissing = System.Reflection.Missing.Value;
            object WdLine = Microsoft.Office.Interop.Word.WdUnits.wdParagraph;
            object oPageBreak = Microsoft.Office.Interop.Word.WdBreakType.wdSectionBreakNextPage;//分页符
            wordApp.Selection.InsertBreak(ref oPageBreak);
            wordApp.Selection.MoveDown(WdLine, 2, oMissing);
            wordApp.Selection.InsertBreak(ref oPageBreak);
            wordApp.Selection.MoveUp(WdLine, 1, oMissing);
            wordApp.Selection.PageSetup.Orientation = Microsoft.Office.Interop.Word.WdOrientation.wdOrientLandscape;



            //绑定数据

            //string sql = "select a.CdPosition ,a.CdId, a.Hit as Hit1 ,b.Hit as Hit2 ,c.Hit as Hit3 from result_observe a,(select CdPosition, CdId,Hit from result_observe where ObserDate ='2011-03-17') b,(select CdPosition, CdId,Hit from result_observe where ObserDate ='2015-03-19') c where a.ObserDate ='2015-11-03' and a.CdId=b.CdId and b.CdId=c.CdId and a.CdPosition=b.CdPosition and b.CdPosition=c.CdPosition";
            //System.Data.DataTable dt = GetDataTable(sql);


            int tableRow = 30;
            int tableColumn = 17;
            //定义一个word中的表格对象
            MSWord.Table table = wordDoc.Tables.Add(wordApp.Selection.Range, tableRow, tableColumn, ref Nothing, ref Nothing);
            //表格的索引是从1开始的
            table.Cell(1, 1).Range.Text = "滨海抽水站河床断面冲淤量比较表\n\n工程竣工日期  2009-12-1  上次观测日期 2014-10-12  本次观测日期  2015-3-25  计算水位 4.00 米";
            table.Cell(2, 1).Range.Text = "断面编号";
            table.Cell(2, 2).Range.Text = "里程";
            table.Cell(2, 3).Range.Text = "计算水位断面宽（m）";
            table.Cell(2, 6).Range.Text = "深泓高程(m) ";
            table.Cell(2, 9).Range.Text = "断面积（m2）";
            table.Cell(2, 12).Range.Text = "断面间距（m）";
            table.Cell(2, 13).Range.Text = "河床容积（m 3 ）";
            table.Cell(2, 16).Range.Text = "间隔冲於量（m 3 ）";
            table.Cell(2, 17).Range.Text = "累计冲於量（m 3 ）";
            table.Cell(3, 3).Range.Text = "标准断面";
            table.Cell(3, 4).Range.Text = "上次观测";
            table.Cell(3, 5).Range.Text = "本次观测";
            table.Cell(3, 6).Range.Text = "标准断面";
            table.Cell(3, 7).Range.Text = "上次观测";
            table.Cell(3, 8).Range.Text = "本次观测";
            table.Cell(3, 9).Range.Text = "标准断面";
            table.Cell(3, 10).Range.Text = "上次观测";
            table.Cell(3, 11).Range.Text = "本次观测";
            table.Cell(3, 13).Range.Text = "标准断面";
            table.Cell(3, 14).Range.Text = "上次观测";
            table.Cell(3, 15).Range.Text = "本次观测";



            //for (int i = 1; i < tableRow; i++)
            //{
            //    for (int j = 1; j < tableColumn; j++)
            //    {
            //        if (i == 1)
            //        {
            //            table.Cell(i, j + 1).Range.Text = "Column " + j;
            //        }
            //        if (j == 1)
            //        {
            //            table.Cell(i + 1, j).Range.Text = "Row " + i;
            //        }
            //        table.Cell(i + 1, j + 1).Range.Text = i + "行 " + j + "列";
            //    }
            //}
            //添加行
            table.Rows.Add(ref Nothing);
            table.Rows[tableRow + 1].Height = 45;
            //设置table样式
            table.Rows.HeightRule = MSWord.WdRowHeightRule.wdRowHeightAtLeast;//列高度至少会是指定的最小值。
            table.Rows.Height = wordApp.CentimetersToPoints(float.Parse("0.8"));//将计量单位从厘米转换为磅（一磅等于 0.035 厘米）

            table.Range.Font.Size = 10.5F;
            table.Range.Font.Bold = 0;
            table.Rows.Alignment = WdRowAlignment.wdAlignRowCenter;//表格居中
            table.Range.ParagraphFormat.Alignment = MSWord.WdParagraphAlignment.wdAlignParagraphCenter;//表格文本居中
            table.Range.Cells.VerticalAlignment = MSWord.WdCellVerticalAlignment.wdCellAlignVerticalCenter;//文本垂直贴到底部
            //设置table边框样式
            table.Borders.OutsideLineStyle = MSWord.WdLineStyle.wdLineStyleSingle;
            table.Borders.InsideLineStyle = MSWord.WdLineStyle.wdLineStyleSingle;

            //table.Rows[1].Range.Font.Bold = 0;
            //table.Rows[1].Range.Font.Size = 12F;
            //table.Cell(1, 1).Range.Font.Size = 10.5F;
            wordApp.Selection.Cells.Height = 15;//所有单元格的高度
            //除第一行外，其他行的行高都设置为20
            table.Rows[1].Height = 25;
            table.Rows[2].Height = 25;
            table.Rows[3].Height = 45;
            //将表格左上角的单元格里的文字（“行” 和 “列”）居右
            //table.Cell(1, 1).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphRight;
            //将表格左上角的单元格里面下面的“列”字移到左边，相比上一行就是将ParagraphFormat改成了Paragraphs[2].Format
            //table.Cell(1, 1).Range.Paragraphs[2].Format.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;

            table.Columns[1].Width = 60;//将第 1列宽度设置为50
            table.Columns[2].Width = 50;
            //将其他列的宽度都设置为75
            for (int i = 3; i <= tableColumn; i++)
            {
                table.Columns[i].Width = 45;
            }


            //添加表头斜线,并设置表头的样式
            //table.Cell(1, 1).Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderDiagonalDown].Visible = true;
            //table.Cell(1, 1).Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderDiagonalDown].Color = Microsoft.Office.Interop.Word.WdColor.wdColorGray60;
            //table.Cell(1, 1).Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderDiagonalDown].LineWidth = Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt;

            //表格边框
            //表格内容行边框
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderHorizontal, Microsoft.Office.Interop.Word.WdColor.wdColorGray20, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth025pt);
            //表格内容列边框
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderVertical, Microsoft.Office.Interop.Word.WdColor.wdColorGray20, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth025pt);
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderLeft, Microsoft.Office.Interop.Word.WdColor.wdColorGray50, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt);
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderRight, Microsoft.Office.Interop.Word.WdColor.wdColorGray50, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt);
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderTop, Microsoft.Office.Interop.Word.WdColor.wdColorGray50, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt);
            SetTableBorderStyle(table, Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom, Microsoft.Office.Interop.Word.WdColor.wdColorGray50, Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt);
            //合并单元格
            for (int i = 4; i < 30; i++)
            {
                for (int j = 1; j <= 11; j++)
                {
                    table.Cell(i, j).Merge(table.Cell(i + 1, j));
                }
                for (int j = 12; j <= 17; j++)
                {
                    table.Cell(i + 1, j).Merge(table.Cell(i + 2, j));
                }
                i++;
            }
            table.Cell(1, 1).Merge(table.Cell(1, 17));//横向合并
            table.Cell(2, 3).Merge(table.Cell(2, 5));
            table.Cell(2, 4).Merge(table.Cell(2, 6));
            table.Cell(2, 5).Merge(table.Cell(2, 7));
            table.Cell(2, 7).Merge(table.Cell(2, 9));
            table.Cell(2, 1).Merge(table.Cell(3, 1));//纵向合并
            table.Cell(2, 2).Merge(table.Cell(3, 2));
            table.Cell(2, 6).Merge(table.Cell(3, 12));
            table.Cell(2, 8).Merge(table.Cell(3, 16));
            table.Cell(2, 9).Merge(table.Cell(3, 17));

            // 计算Word文档页数
            //MSWord.WdStatistic stat = MSWord.WdStatistic.wdStatisticPages;
            //int num = wordDoc.ComputeStatistics(stat, ref  Nothing);

            //DeletePage(num-1, wordDoc);

        }


        /// <summary>
        /// 加下划线
        /// </summary>
        /// <param name="pText"></param>
        /// <param name="wordApp"></param>
        public void InsertUnderLine(string pText, MSWord.Application wordApp)
        {
            wordApp.Selection.TypeText(pText);
            wordApp.Selection.Font.Underline = Microsoft.Office.Interop.Word.WdUnderline.wdUnderlineSingle; //设置下划线
        }


        /// <summary>
        /// 设置边框
        /// </summary>
        /// <param name="table"></param>
        /// <param name="wdBorderType"></param>
        /// <param name="wdColor"></param>
        /// <param name="wdLineWidth"></param>
        private void SetTableBorderStyle(Table table, WdBorderType wdBorderType, WdColor wdColor, WdLineWidth wdLineWidth)
        {
            table.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderVertical].Visible = true;
            table.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderLeft].Color = Microsoft.Office.Interop.Word.WdColor.wdColorGreen;
            table.Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderLeft].LineWidth = Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt;
        }

        //插入分页符
        //public static void InsertBreak()
        //{
        //    Microsoft.Office.Interop.Word.Paragraph para;
        //    para = wordDoc.Content.Paragraphs.Add(ref Nothing);
        //    object pBreak = (int)WdBreakType.wdSectionBreakNextPage;
        //    para.Range.InsertBreak(ref pBreak);
        //}

        /// <summary>
        /// 杀掉winword.exe进程
        /// </summary>   
        public void killWinWordProcess()
        {
            System.Diagnostics.Process[] processes = System.Diagnostics.Process.GetProcessesByName("WINWORD");
            foreach (System.Diagnostics.Process process in processes)
            {
                bool b = process.MainWindowTitle == "";
                if (process.MainWindowTitle == "")
                {
                    process.Kill();
                }
            }
        }

        public void InsertChart()
        {
            //string sql1 = "select a.CdPosition ,a.CdId, a.Hit as Hit1 ,b.Hit as Hit2 ,c.Hit as Hit3 from result_observe a,(select CdPosition, CdId,Hit from result_observe where ObserDate ='" + dateTimePicker3.Value.ToString("yyyy-MM-dd") + "') b,(select CdPosition, CdId,Hit from result_observe where ObserDate ='" + dateTimePicker2.Value.ToString("yyyy-MM-dd") + "') c where a.ObserDate ='" + dateTimePicker1.Value.ToString("yyyy-MM-dd") + "' and a.CdId=b.CdId and b.CdId=c.CdId and a.CdPosition=b.CdPosition and b.CdPosition=c.CdPosition";   
        }

        /// <summary>
        /// 执行查询语句，返回DataTable
        /// </summary>
        /// <param name="sql">查询语句</param>
        /// <returns>DataTable</returns>
        public System.Data.DataTable GetDataTable(string sql)
        {
            using (SqlConnection conn = new SqlConnection(str))
            {
                System.Data.DataTable dt = new System.Data.DataTable();
                try
                {
                    SqlDataAdapter command = new SqlDataAdapter(sql, conn);
                    command.Fill(dt);
                }
                catch (SqlException ex)
                {

                    throw new Exception(ex.Message);
                }
                return dt;
            }
        }


        public int PageCount
        {
            get
            {
                object oMissing = System.Reflection.Missing.Value;

                int pageCount = wordDoc.ComputeStatistics(WdStatistic.wdStatisticPages, oMissing);

                return pageCount;
            }
        }

        public Range GetPages(int pageIndex)
        {
            object objWhat = WdGoToItem.wdGoToPage;
            object objWhich = WdGoToDirection.wdGoToAbsolute;
            object oMissing = System.Reflection.Missing.Value;
            object objPage = pageIndex;
            Range range1 = wordDoc.GoTo(ref objWhat, ref objWhich, ref objPage, ref oMissing);
            Range range2 = range1.GoToNext(WdGoToItem.wdGoToPage);
            object objStart = range1.Start;
            object objEnd = range2.Start;
            if (range1.Start == range2.Start)
                objEnd = wordDoc.Characters.Count;
            return wordDoc.Range(ref objStart, ref objEnd);
        }


        public void DeletePage(int n, MSWord.Document wordDoc)
        {
            //删除指定页
            object oMissing = System.Reflection.Missing.Value;
            int pages = wordDoc.ComputeStatistics(WdStatistic.wdStatisticPages, ref oMissing);
            object objWhat = Microsoft.Office.Interop.Word.WdGoToItem.wdGoToPage;
            object objWhich = Microsoft.Office.Interop.Word.WdGoToDirection.wdGoToAbsolute;
            object objPage = n;//指定页  
            Microsoft.Office.Interop.Word.Range range1 = wordDoc.GoTo(ref objWhat, ref objWhich, ref objPage, ref oMissing);
            Microsoft.Office.Interop.Word.Range range2 = range1.GoToNext(Microsoft.Office.Interop.Word.WdGoToItem.wdGoToPage);
            object objStart = range1.Start;
            object objEnd = range2.Start;
            if (range1.Start == range2.Start)
                objEnd = wordDoc.Characters.Count;//最后一页  
            //string str1=wordDoc.Range(ref objStart, ref objEnd).Text;  
            //MessageBox.Show(str1);  
            //if (string.IsNullOrEmpty(str.Trim()))
            //{
            object Unit = (int)Microsoft.Office.Interop.Word.WdUnits.wdCharacter;
            object Count = 1;
            wordDoc.Range(ref objStart, ref  objEnd).Delete(ref  Unit, ref  Count);
            //}
            MessageBox.Show("删除成功");
        }
    }


}

